]> granicus.if.org Git - gc/commitdiff
Fix VirtualQuery call in case of malloc failure (Win32)
authorIvan Maidanski <ivmai@mail.ru>
Wed, 20 Jun 2018 07:56:19 +0000 (10:56 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 17 Jul 2018 06:05:15 +0000 (09:05 +0300)
* os_dep.c [!REDIRECT_MALLOC && USE_WINALLOC]
(GC_add_current_malloc_heap): Do not call GC_get_allocation_base(new_l)
if new_l is null; cast malloc() result to the type of new_l.

os_dep.c

index f8cf9ca762c37b95e082bd95c35c13cac3f87c50..1e9bbfdb53b7d0356aeab787c8910f5eefcf0cc5 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -1730,11 +1730,12 @@ void GC_register_data_segments(void)
 
   GC_INNER void GC_add_current_malloc_heap(void)
   {
-    struct GC_malloc_heap_list *new_l =
+    struct GC_malloc_heap_list *new_l = (struct GC_malloc_heap_list *)
                  malloc(sizeof(struct GC_malloc_heap_list));
-    void * candidate = GC_get_allocation_base(new_l);
+    void *candidate;
 
-    if (new_l == 0) return;
+    if (NULL == new_l) return;
+    candidate = GC_get_allocation_base(new_l);
     if (GC_is_malloc_heap_base(candidate)) {
       /* Try a little harder to find malloc heap.                       */
         size_t req_size = 10000;