]> granicus.if.org Git - gc/commitdiff
Check thread_local is initialized before accessing thread_key
authorIvan Maidanski <ivmai@mail.ru>
Fri, 23 Jun 2017 08:18:16 +0000 (11:18 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 23 Jun 2017 08:18:16 +0000 (11:18 +0300)
* 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

index 4aae5c9f7e1afae9f06cbd86d2ada158b5d710a8..0919935d28f5aae476206f9013b181aa9dbc4811 100644 (file)
@@ -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,