From 0f5f6df672fcbb759006a898c1b258a837013a72 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 23 Sep 2015 12:47:50 +0000 Subject: [PATCH] Fix bad iterator access. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248375 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Tooling/Core/Replacement.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Tooling/Core/Replacement.cpp b/lib/Tooling/Core/Replacement.cpp index 8de362fae8..838b8042dc 100644 --- a/lib/Tooling/Core/Replacement.cpp +++ b/lib/Tooling/Core/Replacement.cpp @@ -405,7 +405,8 @@ Replacements mergeReplacements(const Replacements &First, for (auto FirstI = First.begin(), SecondI = Second.begin(); FirstI != First.end() || SecondI != Second.end();) { bool NextIsFirst = SecondI == Second.end() || - FirstI->getOffset() < SecondI->getOffset() + Delta; + (FirstI != First.end() && + FirstI->getOffset() < SecondI->getOffset() + Delta); MergedReplacement Merged(NextIsFirst ? *FirstI : *SecondI, NextIsFirst, Delta); ++(NextIsFirst ? FirstI : SecondI); -- 2.40.0