From b6b8f8dccae26f67b6fcf344a2bc3e57591096b6 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Mar 2026 10:41:10 -0300 Subject: [PATCH] [vector] Avoid double-free in draw blob creation Mirror the blob-creation failure fix from vector paint in the SVG draw path. The non-recycled branch handed ownership to hb_blob_create(), which may already run the destroy callback on failure, and then fell into local cleanup that freed the same buffer again. Switch that branch to hb_blob_create_or_fail() so failure reports nullptr without conflicting cleanup. Tested: - meson compile -C build hb-vector-fuzzer Assisted-by: OpenAI Codex --- src/hb-vector-svg-draw.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hb-vector-svg-draw.cc b/src/hb-vector-svg-draw.cc index 99379e33f..dd80f7464 100644 --- a/src/hb-vector-svg-draw.cc +++ b/src/hb-vector-svg-draw.cc @@ -217,7 +217,9 @@ hb_svg_blob_from_buffer (hb_blob_t **recycled_blob, else { hb_svg_blob_meta_set_buffer (meta, data, allocated); - blob = hb_blob_create (data, len, HB_MEMORY_MODE_WRITABLE, meta, hb_svg_blob_meta_destroy); + blob = hb_blob_create_or_fail (data, len, HB_MEMORY_MODE_WRITABLE, meta, hb_svg_blob_meta_destroy); + if (unlikely (!blob)) + return nullptr; } if (unlikely (blob == hb_blob_get_empty ()))