mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[BlockList] Fix a crash if block is empty
Check if the root node is a mapping node before iterating. This fixes a
crash when the YAML file is not the expected format.
(cherry picked from commit 56778b7209)
This commit is contained in:
@@ -115,8 +115,10 @@ void swift::BlockListStore::Implementation::addConfigureFilePath(StringRef path)
|
||||
SM.getLLVMSourceMgr());
|
||||
for (auto DI = Stream.begin(); DI != Stream.end(); ++ DI) {
|
||||
assert(DI != Stream.end() && "Failed to read a document");
|
||||
yaml::Node *N = DI->getRoot();
|
||||
for (auto &pair: *dyn_cast<yaml::MappingNode>(N)) {
|
||||
auto *MapNode = dyn_cast<yaml::MappingNode>(DI->getRoot());
|
||||
if (!MapNode)
|
||||
continue;
|
||||
for (auto &pair: *MapNode) {
|
||||
std::string key = getScalaString(pair.getKey());
|
||||
auto action = llvm::StringSwitch<BlockListAction>(key)
|
||||
#define BLOCKLIST_ACTION(X) .Case(#X, BlockListAction::X)
|
||||
|
||||
Reference in New Issue
Block a user