]> granicus.if.org Git - gc/commitdiff
Fix crash when using GC_malloc_many() as first allocation call
authorBruce Hoult <bruce@hoult.org>
Thu, 29 May 2014 06:16:50 +0000 (18:16 +1200)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 31 May 2014 10:08:55 +0000 (14:08 +0400)
* mallocx.c (GC_CALL GC_generic_malloc_many): Do not dereference
ok_reclaim_list if it is NULL.

mallocx.c

index 6a183f386b5cfbe4ef4ad3fb42697ba568a31725..9df42da5b8a8fd2b81e8e7ab06d86b1b8d9fb047 100644 (file)
--- a/mallocx.c
+++ b/mallocx.c
@@ -278,6 +278,7 @@ GC_API void GC_CALL GC_generic_malloc_many(size_t lb, int k, void **result)
     size_t lg;      /* Length in granules.  */
     signed_word my_bytes_allocd = 0;
     struct obj_kind * ok = &(GC_obj_kinds[k]);
+    struct hblk ** rlh;
     DCL_LOCK_STATE;
 
     GC_ASSERT(lb != 0 && (lb & (GRANULE_BYTES-1)) == 0);
@@ -304,8 +305,8 @@ GC_API void GC_CALL GC_generic_malloc_many(size_t lb, int k, void **result)
       }
     /* First see if we can reclaim a page of objects waiting to be */
     /* reclaimed.                                                  */
-    {
-        struct hblk ** rlh = ok -> ok_reclaim_list;
+    rlh = ok -> ok_reclaim_list;
+    if (rlh != NULL) {
         struct hblk * hbp;
         hdr * hhdr;