summaryrefslogtreecommitdiff
path: root/mallocx.c
diff options
context:
space:
mode:
authorBruce Hoult <bruce@hoult.org>2014-05-29 18:16:50 +1200
committerIvan Maidanski <ivmai@mail.ru>2014-05-31 13:25:46 +0400
commit9854c8e873eaf736231965f890207ce2c0a5511f (patch)
tree20f40f38d067417646437e022e59e9af91ac71a1 /mallocx.c
parent2a3cef3fa4c428ffd25b72b5190cbd3d8e35caa0 (diff)
downloadbdwgc-9854c8e873eaf736231965f890207ce2c0a5511f.tar.gz
Fix crash when using GC_malloc_many() as first allocation call
* mallocx.c (GC_CALL GC_generic_malloc_many): Do not dereference ok_reclaim_list if it is NULL.
Diffstat (limited to 'mallocx.c')
-rw-r--r--mallocx.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/mallocx.c b/mallocx.c
index b559371c..c8895a1f 100644
--- a/mallocx.c
+++ b/mallocx.c
@@ -288,6 +288,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);
@@ -314,8 +315,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;