mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
YAML: Fix crash in the skip method of KeyValueNode class.
This commit changes the 'skip' method in the 'KeyValueNode' class to ensure that it doesn't dereference a null pointer when calling the 'skip' method of its value child node. It also adds a unittest that ensures that the crash doesn't occur. This change is motivated by a patch that implements parsing of YAML block scalars (http://reviews.llvm.org/D9503), as one of the unittests in that patch triggered this problem. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236669 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a7574638e7
commit
9daa4b18f7
@ -253,7 +253,8 @@ public:
|
|||||||
|
|
||||||
void skip() override {
|
void skip() override {
|
||||||
getKey()->skip();
|
getKey()->skip();
|
||||||
getValue()->skip();
|
if (Node *Val = getValue())
|
||||||
|
Val->skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool classof(const Node *N) {
|
static inline bool classof(const Node *N) {
|
||||||
|
@ -141,6 +141,10 @@ TEST(YAMLParser, HandlesEndOfFileGracefully) {
|
|||||||
ExpectParseError("In object hitting EOF", "{\"\"");
|
ExpectParseError("In object hitting EOF", "{\"\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(YAMLParser, HandlesNullValuesInKeyValueNodesGracefully) {
|
||||||
|
ExpectParseError("KeyValueNode with null value", "test: '");
|
||||||
|
}
|
||||||
|
|
||||||
// Checks that the given string can be parsed into an identical string inside
|
// Checks that the given string can be parsed into an identical string inside
|
||||||
// of an array.
|
// of an array.
|
||||||
static void ExpectCanParseString(StringRef String) {
|
static void ExpectCanParseString(StringRef String) {
|
||||||
|
Loading…
Reference in New Issue
Block a user