From 77f5a196502c5b496c4e173c9d12ffbbd6da0839 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Mar 2026 10:21:28 -0300 Subject: [PATCH] [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 --- src/hb-vector-svg-paint.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hb-vector-svg-paint.cc b/src/hb-vector-svg-paint.cc index 0ab69be72..ed9aca95d 100644 --- a/src/hb-vector-svg-paint.cc +++ b/src/hb-vector-svg-paint.cc @@ -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