From 8fb58f6bf022319654d4f32fe53928ab862af364 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 26 Sep 2012 15:52:15 +0000 Subject: [PATCH] YAMLParser: Fix invalid reads when encountering incorrectly quoted scalar. Fixes PR12632. llvm-svn: 164701 --- llvm/lib/Support/YAMLParser.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/llvm/lib/Support/YAMLParser.cpp b/llvm/lib/Support/YAMLParser.cpp index 7c353c89bb84..34df636a72a0 100644 --- a/llvm/lib/Support/YAMLParser.cpp +++ b/llvm/lib/Support/YAMLParser.cpp @@ -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;