[PATCH][Review request] unix.Malloc checker improvement: +handling new/delete, +memory.MismatchedFree, +memory.MismatchedDelete, +improved display names for allocators/deallocators
Anton Yartsev
anton.yartsev at gmail.com
Fri May 24 07:29:56 PDT 2013
>
>> +void testNew11(NSUInteger dataLength) {
>> + int *data = new int;
>> + NSData *nsdata = [NSData dataWithBytesNoCopy:data
>> length:sizeof(int) freeWhenDone:1]; // expected-warning{{Memory
>> allocated by 'new' should be deallocated by 'delete', not
>> +dataWithBytesNoCopy:length:freeWhenDone:}}
>> +}
>
> Hm, that is rather unwieldy, but what bothers me more is that
> +dataWithBytesNoCopy:length:freeWhenDone: /doesn't/ free the memory;
> it just takes ownership of it. I guess it's okay to leave that as a
> FIXME for now, but in the long run we should say something like
> "+dataWithBytesNoCopy:length:freeWhenDone: cannot take ownership of
> memory allocated by 'new'." (In the "hold" cases, most likely the user
> wasn't intending to free
>
> But, this doesn't have to block the patch; you/we can fix it post-commit.
Hi!
Attached patch fixes this. Ok to commit?
--
Anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130524/ab48b263/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OwnershipTransferIsNotDelete.patch
Type: text/x-diff
Size: 3879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130524/ab48b263/attachment.patch>
More information about the cfe-commits
mailing list