[llvm] r318935 - [YAMLParser] Don't crash on null keys in KeyValueNodes.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 23 12:57:21 PST 2017
Author: d0k
Date: Thu Nov 23 12:57:20 2017
New Revision: 318935
URL: http://llvm.org/viewvc/llvm-project?rev=318935&view=rev
Log:
[YAMLParser] Don't crash on null keys in KeyValueNodes.
Found by clangd-fuzzer!
Modified:
llvm/trunk/include/llvm/Support/YAMLParser.h
llvm/trunk/unittests/Support/YAMLParserTest.cpp
Modified: llvm/trunk/include/llvm/Support/YAMLParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/YAMLParser.h?rev=318935&r1=318934&r2=318935&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/YAMLParser.h (original)
+++ llvm/trunk/include/llvm/Support/YAMLParser.h Thu Nov 23 12:57:20 2017
@@ -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) {
Modified: llvm/trunk/unittests/Support/YAMLParserTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/YAMLParserTest.cpp?rev=318935&r1=318934&r2=318935&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/YAMLParserTest.cpp (original)
+++ llvm/trunk/unittests/Support/YAMLParserTest.cpp Thu Nov 23 12:57:20 2017
@@ -180,6 +180,7 @@ TEST(YAMLParser, HandlesEndOfFileGracefu
}
TEST(YAMLParser, HandlesNullValuesInKeyValueNodesGracefully) {
+ ExpectParseError("KeyValueNode with null key", "? \"\n:");
ExpectParseError("KeyValueNode with null value", "test: '");
}
More information about the llvm-commits
mailing list