Skip to content

Commit 20401b9

Browse files
committed
[AST] Avoid possible segfault in isDirectToStorageAccess
`isAccessibleFrom` allows a `nullptr` for `useDC`. Thus `UseDC` can be a `nullptr` in the path `checkAccess` -> `getAccessSemanticsFromContext` -> `isDirectToStorageAccess`. Resolves rdar://104620331. (cherry picked from commit 526016c)
1 parent b0980d9 commit 20401b9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2108,7 +2108,7 @@ static bool isDirectToStorageAccess(const DeclContext *UseDC,
21082108
if (!var->hasStorage())
21092109
return false;
21102110

2111-
auto *AFD = dyn_cast<AbstractFunctionDecl>(UseDC);
2111+
auto *AFD = dyn_cast_or_null<AbstractFunctionDecl>(UseDC);
21122112
if (AFD == nullptr)
21132113
return false;
21142114

0 commit comments

Comments
 (0)