[llvm-commits] [llvm] r155735 - /llvm/trunk/lib/Support/YAMLParser.cpp

Michael J. Spencer bigcheesegs at gmail.com
Fri Apr 27 14:12:20 PDT 2012


Author: mspencer
Date: Fri Apr 27 16:12:20 2012
New Revision: 155735

URL: http://llvm.org/viewvc/llvm-project?rev=155735&view=rev
Log:
[Support/YAMLParser] Fix ASan found bugs.

Modified:
    llvm/trunk/lib/Support/YAMLParser.cpp

Modified: llvm/trunk/lib/Support/YAMLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/YAMLParser.cpp?rev=155735&r1=155734&r2=155735&view=diff
==============================================================================
--- llvm/trunk/lib/Support/YAMLParser.cpp (original)
+++ llvm/trunk/lib/Support/YAMLParser.cpp Fri Apr 27 16:12:20 2012
@@ -755,6 +755,8 @@
 }
 
 StringRef::iterator Scanner::skip_nb_char(StringRef::iterator Position) {
+  if (Position == End)
+    return Position;
   // Check 7 bit c-printable - b-char.
   if (   *Position == 0x09
       || (*Position >= 0x20 && *Position <= 0x7E))
@@ -778,6 +780,8 @@
 }
 
 StringRef::iterator Scanner::skip_b_break(StringRef::iterator Position) {
+  if (Position == End)
+    return Position;
   if (*Position == 0x0D) {
     if (Position + 1 != End && *(Position + 1) == 0x0A)
       return Position + 2;
@@ -1211,7 +1215,9 @@
         ++Current;
       // Repeat until the previous character was not a '\' or was an escaped
       // backslash.
-    } while (*(Current - 1) == '\\' && wasEscaped(Start + 1, Current));
+    } while (   Current != End
+             && *(Current - 1) == '\\'
+             && wasEscaped(Start + 1, Current));
   } else {
     skip(1);
     while (true) {





More information about the llvm-commits mailing list