From: Ivan Maidanski Date: Wed, 20 Jun 2018 07:56:19 +0000 (+0300) Subject: Fix VirtualQuery call in case of malloc failure (Win32) X-Git-Tag: v7.6.8~62 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=976788025564fc7c3b03c5885a72f90d8d16276d;p=gc Fix VirtualQuery call in case of malloc failure (Win32) * 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. --- diff --git a/os_dep.c b/os_dep.c index 249a2cee..9c59095f 100644 --- a/os_dep.c +++ b/os_dep.c @@ -1797,11 +1797,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;