netapi32: Set the buffer to NULL in NetApiBufferFree
John Klehm
xixsimplicityxix at gmail.com
Thu Jun 26 11:05:13 CDT 2008
On Thu, Jun 26, 2008 at 10:50 AM, Juan Lang <juan.lang at gmail.com> wrote:
>> The fix should be
>> *Buffer = NULL;
>> not
>> Buffer = NULL;
>> since p (in the tests) would still be valid after the NetApiBufferFree call.
>
> That's also not correct, as you'd be dereferencing an invalid pointer.
> NetApiBufferFree takes a void *, not a void ** (unlike
> NetApiBufferAllocate).
>
> My question remains: why does setting a local variable to NULL
> silence a Valgrind warning? That sounds like a Valgrind bug to me.
Not that I know anything but it seems that HeapFree calls RtlFreeHeap
and RtlFreeHeap checks to make sure the pointer is not null before
trying to free it. So explicitly setting it to null makes the erorr
go away.
Now trying to free a pointer a second time could maybe be considered
poor logic but I'll leave that up to wiser minds.
Best,
--John Klehm
More information about the wine-devel
mailing list