From: Ivan Maidanski Date: Thu, 24 May 2018 22:08:25 +0000 (+0300) Subject: Fix GC_out_of_line_malloc in new_gc_alloc.h for out-of-memory case X-Git-Tag: v8.0.0~162 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=689b081f19739961085275ace06a82a3bf1dbe5a;p=gc Fix GC_out_of_line_malloc in new_gc_alloc.h for out-of-memory case * include/new_gc_alloc.h (GC_out_of_line_malloc): Call GC_generic_malloc_words_small() before the counters update; do not update the counters if GC_generic_malloc_words_small() returns 0. --- diff --git a/include/new_gc_alloc.h b/include/new_gc_alloc.h index 866136b4..5d459ee4 100644 --- a/include/new_gc_alloc.h +++ b/include/new_gc_alloc.h @@ -148,6 +148,9 @@ size_t GC_aux_template::GC_uncollectable_bytes_recently_freed = 0; template void * GC_aux_template::GC_out_of_line_malloc(size_t nwords, int kind) { + void * op = GC_generic_malloc_words_small(nwords, kind); + if (!op) return 0; + GC_bytes_recently_allocd += GC_uncollectable_bytes_recently_allocd; GC_non_gc_bytes += GC_uncollectable_bytes_recently_allocd; @@ -162,8 +165,7 @@ void * GC_aux_template::GC_out_of_line_malloc(size_t nwords, int kind) GC_incr_bytes_freed(GC_bytes_recently_freed); GC_bytes_recently_freed = 0; - - return GC_generic_malloc_words_small(nwords, kind); + return op; } typedef GC_aux_template<0> GC_aux;