[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
This commit is contained in:
Behdad Esfahbod authored and GitHub committed 2026-03-13 14:32:22 -06:00
1 parent 8fbf89c638
commit c197509b4b
2 files changed
+4 -5

No files matched your search

+4 -5
View File
@@ -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, "<g transform=\"");
hb_svg_append_instance_transform (&body, paint->precision,
hb_svg_append_str (&paint->current_body (), "<g transform=\"");
hb_svg_append_instance_transform (&paint->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, "</g>\n");
hb_svg_append_str (&paint->current_body (), "</g>\n");
return ret;
}