mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
d42326ce80
The hash rebuild process was not GC-safe. When rebuilding the hash table, the old data was orphaned before the new table was fully populated, which could lead to a segmentation fault if a GC cycle was triggered during the process. This patch refactors the rebuild function to follow a safer pattern: - A new temporary hash table is allocated on the stack. - Elements from the original table are copied to the new one. - The original table's data is swapped with the new table's data only after the new table is complete. This ensures the original data is always reachable by the GC during the rebuild. Co-authored-by: Gemini <gemini@google.com>