diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-03 23:43:01 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-03 23:43:01 +0000 |
commit | 25029d499e294bb611c74f525e95cbf0c1d423fe (patch) | |
tree | 485ee1e2388f66b4e5ae9917cc76e4d56c69cb6d /clang/lib/Basic | |
parent | b85400aa5862d1c49741f0cab10fc46255857adc (diff) | |
download | bcm5719-llvm-25029d499e294bb611c74f525e95cbf0c1d423fe.tar.gz bcm5719-llvm-25029d499e294bb611c74f525e95cbf0c1d423fe.zip |
Make sure SourceManager::getFileIDLoaded doesn't hang in release build because of invalid passed parameter.
rdar://10210140
llvm-svn: 141048
Diffstat (limited to 'clang/lib/Basic')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 96a526ad141..a540f3b9450 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -732,6 +732,10 @@ FileID SourceManager::getFileIDLocal(unsigned SLocOffset) const { FileID SourceManager::getFileIDLoaded(unsigned SLocOffset) const { assert(SLocOffset >= CurrentLoadedOffset && "Bad function choice"); + // Sanity checking, otherwise a bug may lead to hanging in release build. + if (SLocOffset < CurrentLoadedOffset) + return FileID(); + // Essentially the same as the local case, but the loaded array is sorted // in the other direction. |