[PATCH] D86231: [SourceManager] Explicitly check for potential iterator underflow

Jan Korous via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 15 15:54:54 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGae726fecae9a: [SourceManager] Explicitly check for potential iterator underflow (authored by jkorous).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86231/new/

https://reviews.llvm.org/D86231

Files:
  clang/lib/Basic/SourceManager.cpp


Index: clang/lib/Basic/SourceManager.cpp
===================================================================
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -1936,6 +1936,11 @@
 
   assert(!MacroArgsCache->empty());
   MacroArgsMap::iterator I = MacroArgsCache->upper_bound(Offset);
+  // In case every element in MacroArgsCache is greater than Offset we can't
+  // decrement the iterator.
+  if (I == MacroArgsCache->begin())
+    return Loc;
+
   --I;
 
   unsigned MacroArgBeginOffs = I->first;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86231.292042.patch
Type: text/x-patch
Size: 530 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200915/eea813de/attachment.bin>


More information about the cfe-commits mailing list