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