Skip to content

Commit 70617e6

Browse files
committed
NSData: free() buffer before throw to prevent memory leak.
1 parent 7042d36 commit 70617e6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Foundation/NSData.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ open class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
406406
}
407407

408408
if remaining != 0 {
409+
free(data)
409410
throw NSError(domain: NSPOSIXErrorDomain, code: Int(errno), userInfo: nil)
410411
}
411412

0 commit comments

Comments
 (0)