Skip to content

Commit 94a0910

Browse files
authored
Don't try to look up info for a null TypeRef (#30640)
This indirectly hardens the `swift_reflection_infoForTypeRef` API against being invoked with a null TypeRef pointer. The API already handles a nullptr being returned from `TypeConverter::getTypeInfo` by converting it into a standard "UNKNOWN" type info descriptor. Resolves rdar://60633988
1 parent b3b3675 commit 94a0910

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

include/swift/Reflection/ReflectionContext.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,11 @@ class ReflectionContext
885885

886886
/// Return a description of the layout of a value with the given type.
887887
const TypeInfo *getTypeInfo(const TypeRef *TR) {
888-
return getBuilder().getTypeConverter().getTypeInfo(TR);
888+
if (TR == nullptr) {
889+
return nullptr;
890+
} else {
891+
return getBuilder().getTypeConverter().getTypeInfo(TR);
892+
}
889893
}
890894

891895
private:

0 commit comments

Comments
 (0)