[vector] Avoid OOM leak in paint initialization

hb_vector_paint_ensure_initialized() used group_stack.push() and
then treated the returned pointer as a normal success indicator.
On allocation failure push() returns the Crap() sentinel, so the
subsequent root->alloc(4096) allocated backing storage into the
failure sink and leaked under malloc-failure fuzzing.

Use push_or_fail() instead and only allocate the root body after a
real push succeeds.

Tested:
- build/test/fuzzing/hb-vector-fuzzer test/fuzzing/fonts/TwemojiMozilla.subset.ttf

Assisted-by: OpenAI Codex
This commit is contained in:
Behdad Esfahbod committed 2026-03-10 10:21:28 -03:00
1 parent 47b0ce552d
commit 77f5a19650
1 file changed
+3 -3
+3 -3
View File
@@ -1016,9 +1016,9 @@ hb_vector_paint_ensure_initialized (hb_vector_paint_t *paint)
{
if (paint->group_stack.length)
return;
auto *root = paint->group_stack.push ();
if (likely (root))
root->alloc (4096);
if (unlikely (!paint->group_stack.push_or_fail ()))
return;
paint->group_stack.tail ().alloc (4096);
}
static void