From c197509b4b2ecad247a016369ce3746d8d75d1ae Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 13 Mar 2026 14:32:22 -0600 Subject: [PATCH] [vector] Avoid stale SVG paint body references (#5843) The non-cached SVG paint path kept a reference to the current group body across hb_font_paint_glyph_or_fail(). Nested paint groups can grow group_stack and move its storage, leaving that reference dangling. Append to current_body() directly before and after the recursive paint call so the code never reuses a body reference after the stack may have reallocated. Fixes: https://oss-fuzz.com/testcase-detail/5622008821121024 Testing: meson test -C build Assisted-by: OpenAI Codex --- src/hb-vector-svg-paint.cc | 9 ++++----- ...se-minimized-hb-vector-fuzzer-5622008821121024 | Bin 0 -> 156 bytes 2 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-vector-fuzzer-5622008821121024 diff --git a/src/hb-vector-svg-paint.cc b/src/hb-vector-svg-paint.cc index b23efb7e3..1853aa3ae 100644 --- a/src/hb-vector-svg-paint.cc +++ b/src/hb-vector-svg-paint.cc @@ -1647,13 +1647,12 @@ hb_vector_paint_glyph (hb_vector_paint_t *paint, return true; } - auto &body = paint->current_body (); - hb_svg_append_str (&body, "precision, + hb_svg_append_str (&paint->current_body (), "current_body (), paint->precision, paint->x_scale_factor, paint->y_scale_factor, xx, yx, xy, yy, tx, ty); - hb_svg_append_str (&body, "\">\n"); + hb_svg_append_str (&paint->current_body (), "\">\n"); hb_codepoint_t old_gid = paint->current_svg_image_glyph; hb_face_t *old_face = paint->current_face; paint->current_svg_image_glyph = glyph; @@ -1664,7 +1663,7 @@ hb_vector_paint_glyph (hb_vector_paint_t *paint, paint->foreground); paint->current_svg_image_glyph = old_gid; paint->current_face = old_face; - hb_svg_append_str (&body, "\n"); + hb_svg_append_str (&paint->current_body (), "\n"); return ret; } diff --git a/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-vector-fuzzer-5622008821121024 b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-vector-fuzzer-5622008821121024 new file mode 100644 index 0000000000000000000000000000000000000000..aac177b3c980b2fb20f0a6371ffb22b374a1af5b GIT binary patch literal 156 zcmeYd3Grv(Q~-mV{NzLi7+_&g05UnCTvi~h1ZFER0M-6iP+(x-1!6E0#Nh#AkPJ-1 g0;C4SfnX3D3jnJ54+J0?AmQxq69i%cP2vOb0m=Or^Z)<= literal 0 HcmV?d00001