Skip to content

Commit aeaaaca

Browse files
committed
Fix memory leak in PropertyListSerialization
rdar://80919378
1 parent d0011ab commit aeaaaca

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/Foundation/PropertyListSerialization.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ open class PropertyListSerialization : NSObject {
6363
var error: Unmanaged<CFError>? = nil
6464
let decoded = withUnsafeMutablePointer(to: &fmt) { (outFmt: UnsafeMutablePointer<CFPropertyListFormat>) -> NSObject? in
6565
withUnsafeMutablePointer(to: &error) { (outErr: UnsafeMutablePointer<Unmanaged<CFError>?>) -> NSObject? in
66-
return unsafeBitCast(CFPropertyListCreateWithData(kCFAllocatorSystemDefault, data._cfObject, CFOptionFlags(CFIndex(opt.rawValue)), outFmt, outErr), to: NSObject.self)
66+
return CFPropertyListCreateWithData(kCFAllocatorSystemDefault, data._cfObject, CFOptionFlags(CFIndex(opt.rawValue)), outFmt, outErr).takeRetainedValue()
6767
}
6868
}
6969
format?.pointee = PropertyListFormat(rawValue: UInt(fmt.rawValue))!
@@ -79,7 +79,7 @@ open class PropertyListSerialization : NSObject {
7979
var error: Unmanaged<CFError>? = nil
8080
let decoded = withUnsafeMutablePointer(to: &fmt) { (outFmt: UnsafeMutablePointer<CFPropertyListFormat>) -> NSObject? in
8181
withUnsafeMutablePointer(to: &error) { (outErr: UnsafeMutablePointer<Unmanaged<CFError>?>) -> NSObject? in
82-
return unsafeBitCast(CFPropertyListCreateWithStream(kCFAllocatorSystemDefault, stream, 0, CFOptionFlags(CFIndex(opt.rawValue)), outFmt, outErr), to: NSObject.self)
82+
return CFPropertyListCreateWithStream(kCFAllocatorSystemDefault, stream, 0, CFOptionFlags(CFIndex(opt.rawValue)), outFmt, outErr).takeRetainedValue()
8383
}
8484
}
8585
format?.pointee = PropertyListFormat(rawValue: UInt(fmt.rawValue))!

0 commit comments

Comments
 (0)