Skip to content

Commit e5d1471

Browse files
committed
AST: Handle malformed PatternBindingDecls in parentDeclForInferredAvailability().
Unfortunately, I don't have reduced reproduction for the crash that motivated this fix, but similar precautions are taken elsewhere when handling PatternBindingDecls.
1 parent 82251f2 commit e5d1471

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/AST/Availability.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,12 @@ AvailabilityInference::parentDeclForInferredAvailability(const Decl *D) {
181181
return NTD;
182182
}
183183

184-
if (auto *PBD = dyn_cast<PatternBindingDecl>(D))
184+
if (auto *PBD = dyn_cast<PatternBindingDecl>(D)) {
185+
if (PBD->getNumPatternEntries() < 1)
186+
return nullptr;
187+
185188
return PBD->getAnchoringVarDecl(0);
189+
}
186190

187191
if (auto *OTD = dyn_cast<OpaqueTypeDecl>(D))
188192
return OTD->getNamingDecl();

0 commit comments

Comments
 (0)