summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2017-11-23 20:57:20 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2017-11-23 20:57:20 +0000
commit0085d3c79a0f66691d9894fd5713c9b3776f9be9 (patch)
tree5f4377c2331688376c0c561a9b88d40f0a93d51c
parent40a1edc30787340350de0c4d5a008a266ec6b06d (diff)
downloadbcm5719-llvm-0085d3c79a0f66691d9894fd5713c9b3776f9be9.tar.gz
bcm5719-llvm-0085d3c79a0f66691d9894fd5713c9b3776f9be9.zip
[YAMLParser] Don't crash on null keys in KeyValueNodes.
Found by clangd-fuzzer! llvm-svn: 318935
-rw-r--r--llvm/include/llvm/Support/YAMLParser.h8
-rw-r--r--llvm/unittests/Support/YAMLParserTest.cpp1
2 files changed, 6 insertions, 3 deletions
diff --git a/llvm/include/llvm/Support/YAMLParser.h b/llvm/include/llvm/Support/YAMLParser.h
index 626507947a7..859c2c1f7b3 100644
--- a/llvm/include/llvm/Support/YAMLParser.h
+++ b/llvm/include/llvm/Support/YAMLParser.h
@@ -291,9 +291,11 @@ public:
Node *getValue();
void skip() override {
- getKey()->skip();
- if (Node *Val = getValue())
- Val->skip();
+ if (Node *Val = getKey()) {
+ Key->skip();
+ if (Node *Val = getValue())
+ Val->skip();
+ }
}
static bool classof(const Node *N) {
diff --git a/llvm/unittests/Support/YAMLParserTest.cpp b/llvm/unittests/Support/YAMLParserTest.cpp
index d411a286830..7962f3ca1ad 100644
--- a/llvm/unittests/Support/YAMLParserTest.cpp
+++ b/llvm/unittests/Support/YAMLParserTest.cpp
@@ -180,6 +180,7 @@ TEST(YAMLParser, HandlesEndOfFileGracefully) {
}
TEST(YAMLParser, HandlesNullValuesInKeyValueNodesGracefully) {
+ ExpectParseError("KeyValueNode with null key", "? \"\n:");
ExpectParseError("KeyValueNode with null value", "test: '");
}
OpenPOWER on IntegriCloud