summaryrefslogtreecommitdiff
path: root/reclaim.c
diff options
context:
space:
mode:
authorHamayama <hamay1010@gmail.com>2017-06-20 11:56:20 +0300
committerIvan Maidanski <ivmai@mail.ru>2017-06-20 11:56:20 +0300
commit77bddd57f77c6dbdc30af4f8ae1315e8fe55054a (patch)
treeae9a50c1dcb54928233fc3e33de2af8f013f88cf /reclaim.c
parentaefa9a7173aa07111787a08702fdadd9761b0987 (diff)
downloadbdwgc-77bddd57f77c6dbdc30af4f8ae1315e8fe55054a.tar.gz
Fix null dereference in reclaim_block if DONT_ADD_BYTE_AT_END
Issue #167 (bdwgc). * reclaim.c (GC_reclaim_block): If ok->ok_reclaim_list is null then do not update hhdr->hb_next (and *rlh).
Diffstat (limited to 'reclaim.c')
-rw-r--r--reclaim.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/reclaim.c b/reclaim.c
index 1b26e927..d3070054 100644
--- a/reclaim.c
+++ b/reclaim.c
@@ -438,10 +438,13 @@ STATIC void GC_reclaim_block(struct hblk *hbp, word report_if_found)
}
} else if (GC_find_leak || !GC_block_nearly_full(hhdr)) {
/* group of smaller objects, enqueue the real work */
- struct hblk **rlh = ok -> ok_reclaim_list + BYTES_TO_GRANULES(sz);
+ struct hblk **rlh = ok -> ok_reclaim_list;
- hhdr -> hb_next = *rlh;
- *rlh = hbp;
+ if (rlh != NULL) {
+ rlh += BYTES_TO_GRANULES(sz);
+ hhdr -> hb_next = *rlh;
+ *rlh = hbp;
+ }
} /* else not worth salvaging. */
/* We used to do the nearly_full check later, but we */
/* already have the right cache context here. Also */