Skip to content

Commit e3b9c98

Browse files
authored
Fix RelativePtr ptrauth in swift_getAssociatedConformanceWitnessSlowImpl to sign *then* cast (#41354)
1 parent 3d4953c commit e3b9c98

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

stdlib/public/runtime/Metadata.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5352,14 +5352,16 @@ static const WitnessTable *swift_getAssociatedConformanceWitnessSlowImpl(
53525352
// Resolve the relative reference to the witness function.
53535353
int32_t offset;
53545354
memcpy(&offset, mangledName.data() + 1, 4);
5355-
auto ptr = detail::applyRelativeOffset(mangledName.data() + 1, offset);
5355+
uintptr_t ptr = detail::applyRelativeOffset(mangledName.data() + 1, offset);
53565356

53575357
// Call the witness function.
5358-
auto witnessFn = (AssociatedWitnessTableAccessFunction *)ptr;
5358+
AssociatedWitnessTableAccessFunction *witnessFn;
53595359
#if SWIFT_PTRAUTH
5360-
witnessFn = ptrauth_sign_unauthenticated(witnessFn,
5361-
ptrauth_key_function_pointer,
5362-
0);
5360+
witnessFn =
5361+
(AssociatedWitnessTableAccessFunction *)ptrauth_sign_unauthenticated(
5362+
(void *)ptr, ptrauth_key_function_pointer, 0);
5363+
#else
5364+
witnessFn = (AssociatedWitnessTableAccessFunction *)ptr;
53635365
#endif
53645366

53655367
auto assocWitnessTable = witnessFn(assocType, conformingType, wtable);

0 commit comments

Comments
 (0)