From 689b081f19739961085275ace06a82a3bf1dbe5a Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 25 May 2018 01:08:25 +0300 Subject: [PATCH] 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. --- include/new_gc_alloc.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/new_gc_alloc.h b/include/new_gc_alloc.h index 866136b..5d459ee 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; -- 2.7.4