]> 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>
Wed, 20 Jun 2018 07:56:19 +0000 (10:56 +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 cb71fe53acb25cba870b73eaff48c25fb417d79e..c24d28e30e24753d8cc2e45ef9ffca7ee8c7bee4 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -1821,11 +1821,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;