mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Runtime] Fix leak in tryDynamicCastBoxedSwiftValue.
The call to swift_unboxFromSwiftValueWithType needs to destroy the value on success when requested in the flags. rdar://problem/44686587
This commit is contained in:
@@ -1922,6 +1922,9 @@ static bool tryDynamicCastBoxedSwiftValue(OpaqueValue *dest,
|
||||
|
||||
#if !SWIFT_OBJC_INTEROP // __SwiftValue is a native class:
|
||||
if (swift_unboxFromSwiftValueWithType(src, dest, targetType)) {
|
||||
// Release the source if we need to.
|
||||
if (flags & DynamicCastFlags::TakeOnSuccess)
|
||||
srcType->vw_destroy(src);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user