Fix NetApiBufferReallocate and add a few tests for the border cases
(thanks to Juan Lang for clarifications).
This commit is contained in:
parent
793bce5cc8
commit
add6726c90
|
@ -60,11 +60,17 @@ NET_API_STATUS WINAPI NetApiBufferReallocate(LPVOID OldBuffer, DWORD NewByteCoun
|
|||
LPVOID* NewBuffer)
|
||||
{
|
||||
TRACE("(%p, %ld, %p)\n", OldBuffer, NewByteCount, NewBuffer);
|
||||
*NewBuffer = HeapReAlloc(GetProcessHeap(), 0, OldBuffer, NewByteCount);
|
||||
if (*NewBuffer)
|
||||
return NERR_Success;
|
||||
else
|
||||
return GetLastError();
|
||||
if (NewByteCount)
|
||||
{
|
||||
*NewBuffer = HeapReAlloc(GetProcessHeap(), 0, OldBuffer, NewByteCount);
|
||||
return *NewBuffer ? NERR_Success : GetLastError();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!HeapFree(GetProcessHeap(), 0, OldBuffer)) return GetLastError();
|
||||
*NewBuffer = 0;
|
||||
return NERR_Success;
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
|
|
|
@ -63,7 +63,14 @@ void run_apibuf_tests(void)
|
|||
ok(dwSize >= 0, "The size");
|
||||
ok(pNetApiBufferSize(NULL, &dwSize) == ERROR_INVALID_PARAMETER, "Error for NULL pointer");
|
||||
|
||||
/* 0-length buffer */
|
||||
/* border reallocate cases */
|
||||
ok(pNetApiBufferReallocate(0, 1500, (LPVOID *) &p) != NERR_Success, "(Re)allocated");
|
||||
ok(p == NULL, "Some memory got allocated");
|
||||
ok(pNetApiBufferAllocate(1024, (LPVOID *)&p) == NERR_Success, "Memory not reserved");
|
||||
ok(pNetApiBufferReallocate(p, 0, (LPVOID *) &p) == NERR_Success, "Not freed");
|
||||
ok(p == NULL, "Pointer not cleared");
|
||||
|
||||
/* 0-length buffer */
|
||||
ok(pNetApiBufferAllocate(0, (LPVOID *)&p) == NERR_Success,
|
||||
"Reserved memory");
|
||||
ok(pNetApiBufferSize(p, &dwSize) == NERR_Success, "Got size");
|
||||
|
|
Loading…
Reference in New Issue