diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -455,8 +455,10 @@ SourceLocation::UIntTy TotalSize) { assert(ExternalSLocEntries && "Don't have an external sloc source"); // Make sure we're not about to run out of source locations. - if (CurrentLoadedOffset - TotalSize < NextLocalOffset) + if (CurrentLoadedOffset < TotalSize || + CurrentLoadedOffset - TotalSize < NextLocalOffset) { return std::make_pair(0, 0); + } LoadedSLocEntryTable.resize(LoadedSLocEntryTable.size() + NumSLocEntries); SLocEntryLoaded.resize(LoadedSLocEntryTable.size()); CurrentLoadedOffset -= TotalSize;