mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-29 17:44:06 +01:00
[map] Fix bad memory access if hb_map.fini() was called twice.
This commit is contained in:
1 parent
8a69e00639
commit
ff4e8c7eac
2 files changed
+15
-5
No files matched your search
+7
-5
@@ -131,11 +131,13 @@ struct hb_hashmap_t
|
||||
}
|
||||
void fini_shallow ()
|
||||
{
|
||||
unsigned size = mask + 1;
|
||||
for (unsigned i = 0; i < size; i++)
|
||||
items[i].~item_t ();
|
||||
hb_free (items);
|
||||
items = nullptr;
|
||||
if (unlikely (!items)) {
|
||||
unsigned size = mask + 1;
|
||||
for (unsigned i = 0; i < size; i++)
|
||||
items[i].~item_t ();
|
||||
hb_free (items);
|
||||
items = nullptr;
|
||||
}
|
||||
population = occupancy = 0;
|
||||
}
|
||||
void fini ()
|
||||
|
||||
@@ -78,6 +78,14 @@ main (int argc, char **argv)
|
||||
assert (v.get_population () == 2);
|
||||
}
|
||||
|
||||
/* Test call fini() twice. */
|
||||
{
|
||||
hb_map_t s;
|
||||
for (int i = 0; i < 16; i++)
|
||||
s.set(i, i+1);
|
||||
s.fini();
|
||||
}
|
||||
|
||||
/* Test initializing from iterator. */
|
||||
{
|
||||
hb_map_t s;
|
||||
|
||||
Reference in new issue
Block a user