summaryrefslogtreecommitdiff
path: root/weakmap.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2023-12-08 15:17:51 -0500
committerPeter Zhu <peter@peterzhu.ca>2023-12-12 09:01:21 -0500
commit33cf8f640bab35c463186ef0856689c22559fbeb (patch)
tree0ce361ab7d02f27526b494f941b1759b3514e1b3 /weakmap.c
parentd313c82f797852037012138284d4e49fdaf284c4 (diff)
Make WeakMap safe for compaction during allocation
During allocation, the table may not have been allocated yet which would crash in the st_foreach.
Diffstat (limited to 'weakmap.c')
-rw-r--r--weakmap.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/weakmap.c b/weakmap.c
index 6d66181ffc..4e568e676b 100644
--- a/weakmap.c
+++ b/weakmap.c
@@ -144,7 +144,9 @@ wmap_compact(void *ptr)
{
struct weakmap *w = ptr;
- st_foreach(w->table, wmap_compact_table_i, (st_data_t)w->table);
+ if (w->table) {
+ st_foreach(w->table, wmap_compact_table_i, (st_data_t)w->table);
+ }
}
static const rb_data_type_t weakmap_type = {