mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01: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! llvm-svn: 215205
This commit is contained in:
parent
9c70c83628
commit
0c2eeeddf1
@ -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