Skip to content

Commit 1b53093

Browse files
committed
correct NSString decoding to account for decodeBytesForKey no longer leaking
1 parent 6555082 commit 1b53093

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Foundation/NSString.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,7 @@ public class NSString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, N
243243
if archiveVersion == 1 {
244244
var length = 0
245245
let buffer = aDecoder.decodeBytesWithReturnedLength(&length)
246-
// note this is no copy because it is not free'd when done from the call to decodeBytesWithReturnedLength
247-
self.init(bytesNoCopy: buffer, length: length, encoding: NSUTF8StringEncoding, freeWhenDone: true)
246+
self.init(bytes: buffer, length: length, encoding: NSUTF8StringEncoding)
248247
} else {
249248
aDecoder.failWithError(NSError(domain: NSCocoaErrorDomain, code: NSCocoaError.CoderReadCorruptError.rawValue, userInfo: [
250249
"NSDebugDescription": "NSString cannot decode class version \(archiveVersion)"
@@ -257,8 +256,7 @@ public class NSString : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, N
257256
} else {
258257
var length = 0
259258
let buffer = UnsafeMutablePointer<Void>(aDecoder.decodeBytesForKey("NS.bytes", returnedLength: &length))
260-
// note this is no copy because it is not free'd when done from the call to decodeBytesForKey
261-
self.init(bytesNoCopy: buffer, length: length, encoding: NSUTF8StringEncoding, freeWhenDone: true)
259+
self.init(bytes: buffer, length: length, encoding: NSUTF8StringEncoding)
262260
}
263261
}
264262

0 commit comments

Comments
 (0)