mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
Fix bug 20125 - clang-format segfaults on bad config.
The problem was in unchecked dyn_cast inside of Input::createHNodes. Patch by Roman Kashitsyn! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215205 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1952807c9c
commit
82acfbfe86
@ -326,7 +326,12 @@ Input::HNode *Input::createHNodes(Node *N) {
|
||||
} else if (MappingNode *Map = dyn_cast<MappingNode>(N)) {
|
||||
MapHNode *mapHNode = new MapHNode(N);
|
||||
for (KeyValueNode &KVN : *Map) {
|
||||
ScalarNode *KeyScalar = dyn_cast<ScalarNode>(KVN.getKey());
|
||||
Node *KeyNode = KVN.getKey();
|
||||
ScalarNode *KeyScalar = dyn_cast<ScalarNode>(KeyNode);
|
||||
if (!KeyScalar) {
|
||||
setError(KeyNode, "Map key must be a scalar");
|
||||
break;
|
||||
}
|
||||
StringStorage.clear();
|
||||
StringRef KeyStr = KeyScalar->getValue(StringStorage);
|
||||
if (!StringStorage.empty()) {
|
||||
|
@ -84,6 +84,13 @@ TEST(YAMLIO, TestMapRead) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(YAMLIO, TestMalformedMapRead) {
|
||||
FooBar doc;
|
||||
Input yin("{foo: 3; bar: 5}", nullptr, suppressErrorMessages);
|
||||
yin >> doc;
|
||||
EXPECT_TRUE(!!yin.error());
|
||||
}
|
||||
|
||||
//
|
||||
// Test the reading of a yaml sequence of mappings
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user