]> granicus.if.org Git - clang/commitdiff
fix segfault (because of erasing after the vector boundaries) when the cached token...
authorNuno Lopes <nunoplopes@sapo.pt>
Sun, 26 Jul 2009 16:36:45 +0000 (16:36 +0000)
committerNuno Lopes <nunoplopes@sapo.pt>
Sun, 26 Jul 2009 16:36:45 +0000 (16:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77159 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPCaching.cpp

index 53aa09c130409cffa38f6f236342b8ca3a1afa8e..808787864bef0a8c406a1f1d661b3c25ade1e976 100644 (file)
@@ -102,7 +102,8 @@ void Preprocessor::AnnotatePreviousCachedTokens(const Token &Tok) {
       assert((BacktrackPositions.empty() || BacktrackPositions.back() < i) &&
              "The backtrack pos points inside the annotated tokens!");
       // Replace the cached tokens with the single annotation token.
-      CachedTokens.erase(AnnotBegin + 1, CachedTokens.begin() + CachedLexPos);
+      if (i < CachedLexPos)
+        CachedTokens.erase(AnnotBegin + 1, CachedTokens.begin() + CachedLexPos);
       *AnnotBegin = Tok;
       CachedLexPos = i;
       return;