Fix a double-overrelease in the TestDataFormatterObjC test program.

llvm-svn: 356160
This commit is contained in:
Adrian Prantl 2019-03-14 15:58:21 +00:00
parent 0a833d0ad2
commit ac093d61c4
1 changed files with 5 additions and 4 deletions

View File

@ -406,9 +406,11 @@ int main (int argc, const char * argv[])
// No-copy versions of NSData initializers use NSConcreteData if over 2^16 elements are specified. // No-copy versions of NSData initializers use NSConcreteData if over 2^16 elements are specified.
unsigned concreteLength = 100000; unsigned concreteLength = 100000;
void *zeroes = calloc(1, concreteLength); void *zeroes1 = calloc(1, concreteLength);
NSData *concreteData = [[NSData alloc] initWithBytesNoCopy:zeroes length:concreteLength]; // initWithBytesNoCopy takes ownership of the buffer.
NSMutableData *concreteMutableData = [[NSMutableData alloc] initWithBytesNoCopy:zeroes length:concreteLength]; NSData *concreteData = [[NSData alloc] initWithBytesNoCopy:zeroes1 length:concreteLength];
void *zeroes2 = calloc(1, concreteLength);
NSMutableData *concreteMutableData = [[NSMutableData alloc] initWithBytesNoCopy:zeroes2 length:concreteLength];
[mutableData appendBytes:"MOREDATA" length:8]; [mutableData appendBytes:"MOREDATA" length:8];
@ -624,7 +626,6 @@ int main (int argc, const char * argv[])
[molecule setAtoms:nil]; [molecule setAtoms:nil];
[molecule setAtoms:[NSMutableArray new]]; [molecule setAtoms:[NSMutableArray new]];
free(zeroes);
[pool drain]; [pool drain];
return 0; return 0;
} }