diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-02-12 21:41:23 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-02-12 21:41:23 +0000 |
commit | 064d88e0f9a3f1deca71b98931361f3f5c9ce192 (patch) | |
tree | 22f0794d667b3be3cfd728eaea3fa69314f06865 /lib/Lex | |
parent | 7243b0f000a68f089b91bf8414f26d4766ebac48 (diff) |
[preprocessing record] Add some sanity checks for the preprocessed entity index
to make sure we don't crash on release if the index is not valid.
rdar://13089714
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175010 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r-- | lib/Lex/PreprocessingRecord.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Lex/PreprocessingRecord.cpp b/lib/Lex/PreprocessingRecord.cpp index d7ebeafdf9..c2a340cae7 100644 --- a/lib/Lex/PreprocessingRecord.cpp +++ b/lib/Lex/PreprocessingRecord.cpp @@ -92,8 +92,10 @@ bool PreprocessingRecord::isEntityInFileID(iterator PPEI, FileID FID) { int Pos = PPEI.Position; if (Pos < 0) { - assert(unsigned(-Pos-1) < LoadedPreprocessedEntities.size() && - "Out-of bounds loaded preprocessed entity"); + if (unsigned(-Pos-1) >= LoadedPreprocessedEntities.size()) { + assert(0 && "Out-of bounds loaded preprocessed entity"); + return false; + } assert(ExternalSource && "No external source to load from"); unsigned LoadedIndex = LoadedPreprocessedEntities.size()+Pos; if (PreprocessedEntity *PPE = LoadedPreprocessedEntities[LoadedIndex]) @@ -113,8 +115,10 @@ bool PreprocessingRecord::isEntityInFileID(iterator PPEI, FileID FID) { FID, SourceMgr); } - assert(unsigned(Pos) < PreprocessedEntities.size() && - "Out-of bounds local preprocessed entity"); + if (unsigned(Pos) >= PreprocessedEntities.size()) { + assert(0 && "Out-of bounds local preprocessed entity"); + return false; + } return isPreprocessedEntityIfInFileID(PreprocessedEntities[Pos], FID, SourceMgr); } |