netapi32: Set the buffer to NULL in NetApiBufferFree
Kai Blin
kai.blin at gmail.com
Thu Jun 26 10:24:32 CDT 2008
On Thursday 26 June 2008 16:34:51 you wrote:
> @@ -52,6 +52,7 @@ NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
> {
> TRACE("(%p)\n", Buffer);
> HeapFree(GetProcessHeap(), 0, Buffer);
> + Buffer = NULL;
> return NERR_Success;
> }
>
> I don't get it. How does setting a local variable to NULL avoid a
> warning about freeing it twice?
>
> I'm not saying the patch is wrong, I'm just saying I don't get how
> Valgrind is tricked by this.
The trick is the test code.
From dlls/netapi32/tests/apibuf.c, lines 44-58
/* test normal logic */
ok(pNetApiBufferAllocate(1024, (LPVOID *)&p) == NERR_Success,
"Reserved memory\n");
ok(pNetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n");
ok(dwSize >= 1024, "The size is correct\n");
ok(pNetApiBufferReallocate(p, 1500, (LPVOID *) &p) == NERR_Success,
"Reallocated\n");
ok(pNetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n");
ok(dwSize >= 1500, "The size is correct\n");
ok(pNetApiBufferFree(p) == NERR_Success, "Freed\n");
/* test errors handling */
ok(pNetApiBufferFree(p) == NERR_Success, "Freed\n"); <-- valgrind warning
Which is to be expected. HeapFree on a NULL pointer doesn't hurt, though. As
this test seems to work on Windows, that seemed like the quickest fix.
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/4acd3570/attachment.pgp
More information about the wine-devel
mailing list