[cfe-commits] r77159 - /cfe/trunk/lib/Lex/PPCaching.cpp

Nuno Lopes nunoplopes at sapo.pt
Sun Jul 26 09:36:59 PDT 2009


Author: nlopes
Date: Sun Jul 26 11:36:45 2009
New Revision: 77159

URL: http://llvm.org/viewvc/llvm-project?rev=77159&view=rev
Log:
fix segfault (because of erasing after the vector boundaries) when the cached token position is at the end

Modified:
    cfe/trunk/lib/Lex/PPCaching.cpp

Modified: cfe/trunk/lib/Lex/PPCaching.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPCaching.cpp?rev=77159&r1=77158&r2=77159&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPCaching.cpp (original)
+++ cfe/trunk/lib/Lex/PPCaching.cpp Sun Jul 26 11:36:45 2009
@@ -102,7 +102,8 @@
       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;





More information about the cfe-commits mailing list