Skip to content

Commit 051b4ce

Browse files
committed
Add a missing check for the number of children before accessing them.
parentDemangling is going to be added as the first child of the return node, so we can't construct one unless we have both children. rdar://77530286 (cherry picked from commit a50c048)
1 parent 3cbec1c commit 051b4ce

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/swift/Remote/MetadataReader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,6 +2474,9 @@ class MetadataReader {
24742474
// Use private declaration names for anonymous context references.
24752475
if (parentDemangling->getKind() == Node::Kind::AnonymousContext
24762476
&& nameNode->getKind() == Node::Kind::Identifier) {
2477+
if (parentDemangling->getNumChildren() < 2)
2478+
return nullptr;
2479+
24772480
auto privateDeclName =
24782481
dem.createNode(Node::Kind::PrivateDeclName);
24792482
privateDeclName->addChild(parentDemangling->getChild(0), dem);

0 commit comments

Comments
 (0)