mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-24 08:21:32 +01:00
[graph] Fix invalid read when map gets resized
I don't fully understand how the old code was wrong, since *v should be evaluated before the set() method call. Yet this seems to fix a bug that could be reproduced with HB_DEBUG_SUBSET_REPACK enabled and the following: $ hb-repacker-fuzzer test/fuzzing/graphs/clusterfuzz-testcase-minimized-hb-repacker-fuzzer-6419865171525632
This commit is contained in:
1 parent
94d4283b12
commit
70b3fbed28
1 file changed
+8
-3
+8
-3
@@ -188,8 +188,10 @@ struct graph_t
|
||||
unsigned incoming_edges () const
|
||||
{
|
||||
if (HB_DEBUG_SUBSET_REPACK)
|
||||
{
|
||||
assert (incoming_edges_ == (single_parent != (unsigned) -1) +
|
||||
(parents.values_ref () | hb_reduce (hb_add, 0)));
|
||||
}
|
||||
return incoming_edges_;
|
||||
}
|
||||
|
||||
@@ -304,10 +306,13 @@ struct graph_t
|
||||
return;
|
||||
}
|
||||
|
||||
const unsigned *v;
|
||||
if (parents.has (old_index, &v) &&
|
||||
parents.set (new_index, *v))
|
||||
const unsigned *pv;
|
||||
if (parents.has (old_index, &pv))
|
||||
{
|
||||
unsigned v = *pv;
|
||||
parents.set (new_index, v);
|
||||
parents.del (old_index);
|
||||
}
|
||||
}
|
||||
|
||||
bool is_leaf () const
|
||||
|
||||
Reference in new issue
Block a user