Skip to content

Commit 4a3612b

Browse files
authored
Merge pull request swiftlang#40955 from al45tair/problem/86368350
[Runtime] Fix a potential NULL pointer dereference.
2 parents 794d0e0 + a0313e9 commit 4a3612b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

stdlib/public/runtime/ProtocolConformance.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -984,13 +984,15 @@ swift_conformsToProtocolMaybeInstantiateSuperclasses(
984984
foundWitness = witness;
985985
foundType = searchType;
986986
} else {
987+
auto foundName = swift_getTypeName(foundType, true);
988+
auto searchName = swift_getTypeName(searchType, true);
987989
swift::warning(RuntimeErrorFlagNone,
988-
"Warning: '%s' conforms to protocol '%s', but it also "
989-
"inherits conformance from '%s'. Relying on a "
990+
"Warning: '%.*s' conforms to protocol '%s', but it also "
991+
"inherits conformance from '%.*s'. Relying on a "
990992
"particular conformance is undefined behaviour.\n",
991-
foundType->getDescription()->Name.get(),
993+
(int)foundName.length, foundName.data,
992994
protocol->Name.get(),
993-
searchType->getDescription()->Name.get());
995+
(int)searchName.length, searchName.data);
994996
}
995997
}
996998
}

test/multifile/protocol-conformance-redundant.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// REQUIRES: executable_test
99
// XFAIL: windows
1010

11-
// CHECK: Warning: 'Sub' conforms to protocol 'Hello', but it also inherits conformance from 'Super'. Relying on a particular conformance is undefined behaviour.
11+
// CHECK: Warning: 'main.Sub' conforms to protocol 'Hello', but it also inherits conformance from 'Def.Super'. Relying on a particular conformance is undefined behaviour.
1212
// CHECK: Hello
1313

1414
import StdlibUnittest

0 commit comments

Comments
 (0)