diff options
| author | Peter Zhu <peter@peterzhu.ca> | 2023-12-08 15:17:51 -0500 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2023-12-12 09:01:21 -0500 |
| commit | 33cf8f640bab35c463186ef0856689c22559fbeb (patch) | |
| tree | 0ce361ab7d02f27526b494f941b1759b3514e1b3 /weakmap.c | |
| parent | d313c82f797852037012138284d4e49fdaf284c4 (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.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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 = { |
