Skip to content

Commit f5890ce

Browse files
Merge pull request #80734 from cachemeifyoucan/eng/PR-yaml-blocklist-malformed
[BlockList] Fix a crash if block is empty
2 parents 2dd49f5 + 56778b7 commit f5890ce

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/Basic/BlockList.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ void swift::BlockListStore::Implementation::addConfigureFilePath(StringRef path)
115115
SM.getLLVMSourceMgr());
116116
for (auto DI = Stream.begin(); DI != Stream.end(); ++ DI) {
117117
assert(DI != Stream.end() && "Failed to read a document");
118-
yaml::Node *N = DI->getRoot();
119-
for (auto &pair: *dyn_cast<yaml::MappingNode>(N)) {
118+
auto *MapNode = dyn_cast<yaml::MappingNode>(DI->getRoot());
119+
if (!MapNode)
120+
continue;
121+
for (auto &pair: *MapNode) {
120122
std::string key = getScalaString(pair.getKey());
121123
auto action = llvm::StringSwitch<BlockListAction>(key)
122124
#define BLOCKLIST_ACTION(X) .Case(#X, BlockListAction::X)

0 commit comments

Comments
 (0)