From 3b16a75d1db40a052123b0cdce7d4bb17a5e32d6 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 23 Jun 2017 11:18:16 +0300 Subject: Check thread_local is initialized before accessing thread_key * thread_local_alloc.c [GC_GCJ_SUPPORT] (GC_gcj_malloc): Move GC_ASSERT(GC_gcj_malloc_initialized) to be before accessing GC_thread_key. --- thread_local_alloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'thread_local_alloc.c') diff --git a/thread_local_alloc.c b/thread_local_alloc.c index 4aae5c9f..0919935d 100644 --- a/thread_local_alloc.c +++ b/thread_local_alloc.c @@ -227,9 +227,10 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_gcj_malloc(size_t bytes, } else { size_t granules = ROUNDED_UP_GRANULES(bytes); void *result; - void **tiny_fl = ((GC_tlfs)GC_getspecific(GC_thread_key)) - -> gcj_freelists; + void **tiny_fl; + GC_ASSERT(GC_gcj_malloc_initialized); + tiny_fl = ((GC_tlfs)GC_getspecific(GC_thread_key))->gcj_freelists; GC_FAST_MALLOC_GRANS(result, granules, tiny_fl, DIRECT_GRANULES, GC_gcj_kind, GC_core_gcj_malloc(bytes, -- cgit v1.2.1