YAMLParser: Fix invalid reads when encountering incorrectly quoted scalar.
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 26 Sep 2012 15:52:15 +0000 (15:52 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 26 Sep 2012 15:52:15 +0000 (15:52 +0000)
Fixes PR12632.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164701 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/YAMLParser.cpp

index 7c353c89bb842a86089ef716a7edcdcb426db05a..34df636a72a06a12e4534223b7ef4eae679a6b46 100644 (file)
@@ -903,6 +903,7 @@ bool Scanner::consume(uint32_t Expected) {
 void Scanner::skip(uint32_t Distance) {
   Current += Distance;
   Column += Distance;
+  assert(Current <= End && "Skipped past the end");
 }
 
 bool Scanner::isBlankOrBreak(StringRef::iterator Position) {
@@ -1239,6 +1240,12 @@ bool Scanner::scanFlowScalar(bool IsDoubleQuoted) {
       }
     }
   }
+
+  if (Current == End) {
+    setError("Expected quote at end of scalar", Current);
+    return false;
+  }
+
   skip(1); // Skip ending quote.
   Token T;
   T.Kind = Token::TK_Scalar;