Skip to content

Commit 28b5a68

Browse files
committed
Serialization: Harden deserializeVar
1 parent e44afe1 commit 28b5a68

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3810,14 +3810,22 @@ class DeclDeserializer {
38103810
AddAttribute(new (ctx) HasStorageAttr(/*isImplicit:*/true));
38113811

38123812
if (opaqueReturnTypeID) {
3813+
auto opaqueReturnType = MF.getDeclChecked(opaqueReturnTypeID);
3814+
if (!opaqueReturnType)
3815+
return opaqueReturnType.takeError();
3816+
38133817
ctx.evaluator.cacheOutput(
38143818
OpaqueResultTypeRequest{var},
3815-
cast<OpaqueTypeDecl>(MF.getDecl(opaqueReturnTypeID)));
3819+
cast<OpaqueTypeDecl>(opaqueReturnType.get()));
38163820
}
38173821

38183822
// If this is a lazy property, record its backing storage.
38193823
if (lazyStorageID) {
3820-
VarDecl *storage = cast<VarDecl>(MF.getDecl(lazyStorageID));
3824+
auto lazyStorageDecl = MF.getDeclChecked(lazyStorageID);
3825+
if (!lazyStorageDecl)
3826+
return lazyStorageDecl.takeError();
3827+
3828+
VarDecl *storage = cast<VarDecl>(lazyStorageDecl.get());
38213829
ctx.evaluator.cacheOutput(
38223830
LazyStoragePropertyRequest{var}, std::move(storage));
38233831
}

0 commit comments

Comments
 (0)