mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 06:21:16 +01:00
hb_hashmap_t::update() iterates other's items array while inserting each pair into *this with set(). When other is *this and occupancy sits on a growth threshold (5 of 8, 10 of 16, ...), the first set() calls alloc(), which frees the items array the iterator is still walking, so the rest of the loop reads freed memory. The existing in_storage() guard only protects set()'s own key/value references, not this iterator. Merging a map into itself cannot change it, so make update() a no-op in that case with an early &other == this return, mirroring the self-check in hb_vector_t. hb_map_update() is the only caller. Regression tests are added in src/test-map.cc (including the tombstone case at 42 used / 10 live slots) and test/api/test-map.c; both fail under ASan without the fix. Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-7TMM2Z2T. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>