netapi32: Set the buffer to NULL in NetApiBufferFree

Kai Blin kai.blin at gmail.com
Thu Jun 26 12:34:00 CDT 2008


On Thursday 26 June 2008 18:07:59 you wrote:
> > 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.
>
> That might be true if setting Buffer to NULL happened before the call
> to HeapFree, but it happens after.  After the return from
> NetApiBufferFree, Buffer goes out of scope, and a subsequent call
> won't be affected by it.

You said Buffer was a local variable, but it's a parameter passed from the 
test.

So, as far as I can see, the test does

Buffer = HeapAlloc(GetProcessHeap(), NULL, 1024);

HeapReAlloc(GetProcessHeap(),  0, Buffer, 1500);

HeapFree(GetProcessHeap(), 0, Buffer);
HeapFree(GetProcessHeap(), 0, Buffer);

That's a double free, right? Valgrind is complaining about the second one. 
HeapFree() on a NULL buffer doesn't do anything, so it's not causing a 
Valgrind error anymore.

Cheers,
Kai

-- 
Kai Blin
WorldForge developer  http://www.worldforge.org/
Wine developer        http://wiki.winehq.org/KaiBlin
Samba team member     http://www.samba.org/samba/team/
--
Will code for cotton.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20080626/bd56f3d3/attachment.pgp 


More information about the wine-devel mailing list