aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/PPCaching.cpp
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2009-07-26 16:36:45 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2009-07-26 16:36:45 +0000
commit1b68f71da2fc9e3771f81e8aa72d59bb26158bec (patch)
treeb58553ce78d1a54dcd9a67b1e161662c222a3827 /lib/Lex/PPCaching.cpp
parentec9fd769d0bf3fe8b20790f5c34e9484da006eac (diff)
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
Diffstat (limited to 'lib/Lex/PPCaching.cpp')
-rw-r--r--lib/Lex/PPCaching.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Lex/PPCaching.cpp b/lib/Lex/PPCaching.cpp
index 53aa09c130..808787864b 100644
--- a/lib/Lex/PPCaching.cpp
+++ b/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;