From a3e553a22cfbab757fc519d9f13ec6ade4149e15 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. llvm-svn: 248375 --- clang/lib/Tooling/Core/Replacement.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Tooling/Core/Replacement.cpp b/clang/lib/Tooling/Core/Replacement.cpp index 8de362fae8ec..838b8042dc1e 100644 --- a/clang/lib/Tooling/Core/Replacement.cpp +++ b/clang/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);