[cfe-commits] [PATCH] [Valgrind] Don't read beyond SourceLineCache

NAKAMURA Takumi geek4civic at gmail.com
Fri Dec 14 08:56:08 PST 2012

Hi doug.gregor,

It fixes dozen of failures with --vg.

I have no idea whether it would be right thing. Or, in ComputeLineNumbers(), should LineOffsets have a sentinel in its tail?



Index: clang/lib/Basic/SourceManager.cpp
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -1032,6 +1032,7 @@
   // See if we just calculated the line number for this FilePos and can use
   // that to lookup the start of the line instead of searching for it.
   if (LastLineNoFileIDQuery == FID &&
+      LastLineNoResult < LastLineNoContentCache->NumLines &&
       LastLineNoContentCache->SourceLineCache != 0) {
     unsigned *SourceLineCache = LastLineNoContentCache->SourceLineCache;
     unsigned LineStart = SourceLineCache[LastLineNoResult - 1];
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D217.1.patch
Type: text/x-patch
Size: 651 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121214/503298fd/attachment.bin>

More information about the cfe-commits mailing list