File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -1027,19 +1027,29 @@ swift::swift_getObjCClassMetadata(const ClassMetadata *theClass) {
1027
1027
1028
1028
const ClassMetadata *
1029
1029
swift::swift_getObjCClassFromMetadata (const Metadata *theMetadata) {
1030
+ // We're not supposed to accept NULL, but older runtimes somehow did as a
1031
+ // side effect of UB in dyn_cast, so we'll keep that going.
1032
+ if (!theMetadata)
1033
+ return nullptr ;
1034
+
1030
1035
// Unwrap ObjC class wrappers.
1031
- if (auto wrapper = dyn_cast_or_null <ObjCClassWrapperMetadata>(theMetadata)) {
1036
+ if (auto wrapper = dyn_cast <ObjCClassWrapperMetadata>(theMetadata)) {
1032
1037
return wrapper->Class ;
1033
1038
}
1034
1039
1035
1040
// Otherwise, the input should already be a Swift class object.
1036
1041
auto theClass = cast<ClassMetadata>(theMetadata);
1037
- assert (!theClass || theClass->isTypeMetadata ());
1042
+ assert (theClass->isTypeMetadata ());
1038
1043
return theClass;
1039
1044
}
1040
1045
1041
1046
const ClassMetadata *
1042
1047
swift::swift_getObjCClassFromMetadataConditional (const Metadata *theMetadata) {
1048
+ // We're not supposed to accept NULL, but older runtimes somehow did as a
1049
+ // side effect of UB in dyn_cast, so we'll keep that going.
1050
+ if (!theMetadata)
1051
+ return nullptr ;
1052
+
1043
1053
// If it's an ordinary class, return it.
1044
1054
if (auto theClass = dyn_cast<ClassMetadata>(theMetadata)) {
1045
1055
return theClass;
You can’t perform that action at this time.
0 commit comments