summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Support/YAMLParser.cpp4
-rw-r--r--llvm/unittests/Support/YAMLParserTest.cpp11
2 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/Support/YAMLParser.cpp b/llvm/lib/Support/YAMLParser.cpp
index 333648dae2b..d17e7b227f4 100644
--- a/llvm/lib/Support/YAMLParser.cpp
+++ b/llvm/lib/Support/YAMLParser.cpp
@@ -2288,8 +2288,8 @@ Document::Document(Stream &S) : stream(S), Root(nullptr) {
bool Document::skip() {
if (stream.scanner->failed())
return false;
- if (!Root)
- getRoot();
+ if (!Root && !getRoot())
+ return false;
Root->skip();
Token &T = peekNext();
if (T.Kind == Token::TK_StreamEnd)
diff --git a/llvm/unittests/Support/YAMLParserTest.cpp b/llvm/unittests/Support/YAMLParserTest.cpp
index 06d4b0e269b..938a6ab2a39 100644
--- a/llvm/unittests/Support/YAMLParserTest.cpp
+++ b/llvm/unittests/Support/YAMLParserTest.cpp
@@ -331,4 +331,15 @@ TEST(YAMLParser, DifferentNodesIteratorOperatorEquals) {
EXPECT_TRUE(End == AnotherEnd);
}
+TEST(YAMLParser, FlowSequenceTokensOutsideFlowSequence) {
+ auto FlowSequenceStrs = {",", "]", "}"};
+ SourceMgr SM;
+
+ for (auto &Str : FlowSequenceStrs) {
+ yaml::Stream Stream(Str, SM);
+ yaml::Document &Doc = *Stream.begin();
+ EXPECT_FALSE(Doc.skip());
+ }
+}
+
} // end namespace llvm
OpenPOWER on IntegriCloud