From c762f5d7af863a133ab98f94cd7a827de45137f7 Mon Sep 17 00:00:00 2001 From: "Dimitrie O. Paun" Date: Tue, 25 Nov 2003 01:02:02 +0000 Subject: [PATCH] RtlHeapReAllocate() should not allocate memory. Add small test to make sure it doesn't return. Don't import ntdll for tests, we need to load it dynamically. --- dlls/kernel/tests/.cvsignore | 1 + dlls/kernel/tests/Makefile.in | 1 + dlls/kernel/tests/heap.c | 44 +++++++++++++++++++++++++++++++++++ dlls/ntdll/heap.c | 4 ++-- dlls/ntdll/tests/Makefile.in | 2 +- 5 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 dlls/kernel/tests/heap.c diff --git a/dlls/kernel/tests/.cvsignore b/dlls/kernel/tests/.cvsignore index 49754c6516a..81340c41ecd 100644 --- a/dlls/kernel/tests/.cvsignore +++ b/dlls/kernel/tests/.cvsignore @@ -10,6 +10,7 @@ environ.ok file.ok format_msg.ok generated.ok +heap.ok kernel32_test.exe.spec.c locale.ok mailslot.ok diff --git a/dlls/kernel/tests/Makefile.in b/dlls/kernel/tests/Makefile.in index 81697e06465..68e134e3d42 100644 --- a/dlls/kernel/tests/Makefile.in +++ b/dlls/kernel/tests/Makefile.in @@ -17,6 +17,7 @@ CTESTS = \ file.c \ format_msg.c \ generated.c \ + heap.c \ locale.c \ mailslot.c \ path.c \ diff --git a/dlls/kernel/tests/heap.c b/dlls/kernel/tests/heap.c new file mode 100644 index 00000000000..7c2c58e5253 --- /dev/null +++ b/dlls/kernel/tests/heap.c @@ -0,0 +1,44 @@ +/* + * Unit test suite for heap functions + * + * Copyright 2003 Dimitrie O. Paun + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include + +#include "ntstatus.h" +#include "windef.h" +#include "winbase.h" +#include "wine/test.h" +#include "winnt.h" +#include "winnls.h" +#include "winreg.h" +#include "winternl.h" + +static void test_realloc( void ) +{ + void *mem = NULL; + + mem = HeapReAlloc(GetProcessHeap(), 0, mem, 10); + ok(mem == NULL, "memory allocated"); +} + +START_TEST(heap) +{ + test_realloc(); +} diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 3c6eae02aee..ecfe30c57e3 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -1231,11 +1231,11 @@ PVOID WINAPI RtlReAllocateHeap( HANDLE heap, ULONG flags, PVOID ptr, ULONG size HEAP *heapPtr; SUBHEAP *subheap; - if (!ptr) return RtlAllocateHeap( heap, flags, size ); /* FIXME: correct? */ + if (!ptr) return NULL; if (!(heapPtr = HEAP_GetPtr( heap ))) { set_status( STATUS_INVALID_HANDLE ); - return FALSE; + return NULL; } /* Validate the parameters */ diff --git a/dlls/ntdll/tests/Makefile.in b/dlls/ntdll/tests/Makefile.in index 362a61e497f..3b05ba80a5d 100644 --- a/dlls/ntdll/tests/Makefile.in +++ b/dlls/ntdll/tests/Makefile.in @@ -3,7 +3,7 @@ TOPOBJDIR = ../../.. SRCDIR = @srcdir@ VPATH = @srcdir@ TESTDLL = ntdll.dll -IMPORTS = ntdll +IMPORTS = kernel32 CTESTS = \ env.c \