diff --git a/Source/NSData.m b/Source/NSData.m index a6973ebf62..c5bf2017ff 100644 --- a/Source/NSData.m +++ b/Source/NSData.m @@ -3548,6 +3548,8 @@ - (instancetype) initWithBytesNoCopy: (void*)buf } GSClassSwizzle(self, dataBlock); + bytes = buf; + length = len; ASSIGN(deallocator, (id)deallocBlock); return self; } diff --git a/Tests/base/NSData/general.m b/Tests/base/NSData/general.m index 8780d1f59e..54b24963a0 100644 --- a/Tests/base/NSData/general.m +++ b/Tests/base/NSData/general.m @@ -89,6 +89,8 @@ int main() deallocator: ^(void* bytes, NSUInteger length) { called++; }]; + PASS([immutable length] == 4, "Length set"); + PASS([immutable bytes] == stackBuf, "Bytes set"); PASS_RUNS([immutable release]; immutable = nil;, "No free() error with custom deallocator"); PASS(called == 1, "Deallocator block called"); @@ -102,6 +104,8 @@ int main() called++; } ]; + PASS([mutable length] == 4, "Length set"); + PASS([mutable bytes] == buf, "Bytes set"); PASS_RUNS([mutable release]; mutable = nil;, "No free() error with custom deallocator on mutable data"); PASS(called == 2, "Deallocator block called on -dealloc of mutable data");