Skip to content

Commit d23f4d7

Browse files
authored
Merge pull request #1455 from mamabusi/nsdataleak-branch
2 parents aab4b8a + 14dbaca commit d23f4d7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

CoreFoundation/Collections.subproj/CFData.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,11 @@ CFTypeID CFDataGetTypeID(void) {
330330
void _CFDataInit(CFMutableDataRef memory, CFOptionFlags variety, CFIndex capacity, const uint8_t *bytes, CFIndex length, Boolean noCopy) {
331331
Boolean isMutable = ((variety & __kCFMutableMask) != 0);
332332
Boolean isGrowable = ((variety & __kCFGrowableMask) != 0);
333+
Boolean isDontDeallocate = ((variety & __kCFDontDeallocate) != 0);
333334

334335
__CFDataSetNumBytesUsed(memory, 0);
335336
__CFDataSetLength(memory, 0);
336-
__CFDataSetDontDeallocate(memory, true);
337+
__CFDataSetDontDeallocate(memory, isDontDeallocate);
337338

338339
if (isMutable && isGrowable) {
339340
__CFDataSetCapacity(memory, __CFDataRoundUpCapacity(1));

Foundation/NSData.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,10 @@ private final class _NSDataDeallocator {
6969

7070
private let __kCFMutable: CFOptionFlags = 0x01
7171
private let __kCFGrowable: CFOptionFlags = 0x02
72-
private let __kCFMutableVarietyMask: CFOptionFlags = 0x03
73-
private let __kCFBytesInline: CFOptionFlags = 0x04
74-
private let __kCFUseAllocator: CFOptionFlags = 0x08
75-
private let __kCFDontDeallocate: CFOptionFlags = 0x10
76-
private let __kCFAllocatesCollectable: CFOptionFlags = 0x20
72+
73+
private let __kCFBytesInline: CFOptionFlags = 2
74+
private let __kCFUseAllocator: CFOptionFlags = 3
75+
private let __kCFDontDeallocate: CFOptionFlags = 4
7776

7877
open class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
7978
typealias CFType = CFData

0 commit comments

Comments
 (0)