Skip to content

Commit b7f73cd

Browse files
committed
[Runtime] Gracefully handle null genericArgs in SubstGenericParametersFromMetadata.
If a caller passes NULL generic parameters when looking up a generic type, we'll error and return NULL instead of crashing. rdar://112153818
1 parent 1f99204 commit b7f73cd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

stdlib/public/runtime/MetadataLookup.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3063,6 +3063,10 @@ void SubstGenericParametersFromMetadata::setup() const {
30633063
MetadataOrPack
30643064
SubstGenericParametersFromMetadata::getMetadata(
30653065
unsigned depth, unsigned index) const {
3066+
// Don't attempt anything if we have no generic parameters.
3067+
if (genericArgs == nullptr)
3068+
return MetadataOrPack();
3069+
30663070
// On first access, compute the descriptor path.
30673071
setup();
30683072

@@ -3104,6 +3108,10 @@ SubstGenericParametersFromMetadata::getMetadata(
31043108
const WitnessTable *
31053109
SubstGenericParametersFromMetadata::getWitnessTable(const Metadata *type,
31063110
unsigned index) const {
3111+
// Don't attempt anything if we have no generic parameters.
3112+
if (genericArgs == nullptr)
3113+
return nullptr;
3114+
31073115
// On first access, compute the descriptor path.
31083116
setup();
31093117

0 commit comments

Comments
 (0)