瀏覽代碼

fix segfault (because of erasing after the vector boundaries) when the cached token position is at the end

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77159 91177308-0d34-0410-b5e6-96231b3b80d8
Nuno Lopes 16 年之前
父節點
當前提交
1b68f71da2
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      lib/Lex/PPCaching.cpp

+ 2 - 1
lib/Lex/PPCaching.cpp

@@ -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;