summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-02-12 21:41:23 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-02-12 21:41:23 +0000
commit962b2210ccfe25bb87d3a13d3b8c38b1a825781f (patch)
tree48e04821ca7427ed878945cb6564014bb3237ccf /clang/lib/Lex
parent3ea602cd30ed6062a55100a29e2979f37f225545 (diff)
downloadbcm5719-llvm-962b2210ccfe25bb87d3a13d3b8c38b1a825781f.tar.gz
bcm5719-llvm-962b2210ccfe25bb87d3a13d3b8c38b1a825781f.zip
[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 llvm-svn: 175010
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r--clang/lib/Lex/PreprocessingRecord.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Lex/PreprocessingRecord.cpp b/clang/lib/Lex/PreprocessingRecord.cpp
index d7ebeafdf95..c2a340cae79 100644
--- a/clang/lib/Lex/PreprocessingRecord.cpp
+++ b/clang/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);
}
OpenPOWER on IntegriCloud