heap: fix RtlHeapReAllocate()

Dimitrie O. Paun dpaun at rogers.com
Mon Nov 24 01:25:42 CST 2003


On November 21, 2003 03:21 pm, Eric Pouech wrote:
> this will not compile on Win9x. You have to take care of:

Good point, sorry about that, I was being lazy. To force people
to do the dyn load, we shouldn't import ntdll, no?

ChangeLog
   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.

Index: dlls/ntdll/heap.c
===================================================================
RCS file: /var/cvs/wine/dlls/ntdll/heap.c,v
retrieving revision 1.25
diff -u -r1.25 heap.c
--- dlls/ntdll/heap.c	10 Oct 2003 00:12:17 -0000	1.25
+++ dlls/ntdll/heap.c	20 Nov 2003 21:00:39 -0000
@@ -1231,11 +1231,11 @@
     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 */
Index: dlls/ntdll/tests/Makefile.in
===================================================================
RCS file: /var/cvs/wine/dlls/ntdll/tests/Makefile.in,v
retrieving revision 1.9
diff -u -r1.9 Makefile.in
--- dlls/ntdll/tests/Makefile.in	8 May 2003 03:47:24 -0000	1.9
+++ dlls/ntdll/tests/Makefile.in	24 Nov 2003 07:19:04 -0000
@@ -3,12 +3,12 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 TESTDLL   = ntdll.dll
-IMPORTS   = ntdll
 
 CTESTS = \
 	env.c \
 	error.c \
 	generated.c \
+	heap.c \
 	large_int.c \
 	path.c \
 	rtl.c \
--- /dev/null	2003-01-30 05:24:37.000000000 -0500
+++ dlls/ntdll/tests/heap.c	2003-11-24 02:17:07.000000000 -0500
@@ -0,0 +1,49 @@
+/*
+ * 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 <stdarg.h>
+#include <stdlib.h>
+
+#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"
+
+PVOID     (WINAPI *pRtlReAllocateHeap)(HANDLE,ULONG,PVOID,ULONG);
+
+static void test_realloc( void )
+{
+    void *mem = NULL;
+
+    mem = pRtlReAllocateHeap(GetProcessHeap(), 0, mem, 10);
+    ok(mem == NULL, "memory allocated");
+}
+
+START_TEST(heap)
+{
+    HMODULE mod = GetModuleHandle("ntdll.dll");
+    if (!mod) return;
+    pRtlReAllocateHeap = (void *)GetProcAddress(mod, "RtlReAllocateHeap");
+    if (pRtlReAllocateHeap) test_realloc();
+}


-- 
Dimi.




More information about the wine-patches mailing list