From 25bfb5adc3a60af8c4c54922b04e0bdb837fd788 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 14 Apr 2026 20:52:07 -0600 Subject: [PATCH 1/8] [vector-paint/pdf] Check color-stops vector resize under failing-malloc Two sites queried color-stop count, resized the scratch vector to match, then called hb_color_line_get_color_stops() passing the requested count as the write capacity. If the resize() failed (OOM), the vector stayed at its previous (smaller) length while the callee still wrote the full requested count -- heap-buffer- overflow. Fixed by checking resize() and bailing: build_gradient_function returns 0, paint_sweep_gradient returns. Matches the pattern already used in hb-raster-paint.cc and hb-vector-paint.cc. Found by oss-fuzz/CIFuzz on hb-vector-fuzzer against a sweep- gradient COLRv1 glyph under failing-malloc. Assisted-by: Claude --- src/hb-vector-paint-pdf.cc | 6 ++++-- ...e-minimized-hb-vector-fuzzer-5620949889384448 | Bin 0 -> 3492 bytes ...e-minimized-hb-vector-fuzzer-6727871677923328 | Bin 0 -> 2931 bytes 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-vector-fuzzer-5620949889384448 create mode 100644 test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-vector-fuzzer-6727871677923328 diff --git a/src/hb-vector-paint-pdf.cc b/src/hb-vector-paint-pdf.cc index 805b14d73..bddb5e69e 100644 --- a/src/hb-vector-paint-pdf.cc +++ b/src/hb-vector-paint-pdf.cc @@ -731,7 +731,8 @@ hb_pdf_build_gradient_function (hb_pdf_resources_t *res, hb_color_line_t *color_line) { unsigned count = hb_color_line_get_color_stops (color_line, 0, nullptr, nullptr); - paint->color_stops_scratch.resize (count); + if (unlikely (!paint->color_stops_scratch.resize (count))) + return 0; hb_color_line_get_color_stops (color_line, 0, &count, paint->color_stops_scratch.arrayZ); if (count < 2) @@ -1042,7 +1043,8 @@ hb_pdf_paint_sweep_gradient (hb_paint_funcs_t *, /* Get and sort color stops. */ unsigned n_stops = hb_color_line_get_color_stops (color_line, 0, nullptr, nullptr); - paint->color_stops_scratch.resize (n_stops); + if (unlikely (!paint->color_stops_scratch.resize (n_stops))) + return; hb_color_line_get_color_stops (color_line, 0, &n_stops, paint->color_stops_scratch.arrayZ); paint->color_stops_scratch.as_array ().qsort ( [] (const hb_color_stop_t &a, const hb_color_stop_t &b) diff --git a/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-vector-fuzzer-5620949889384448 b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-vector-fuzzer-5620949889384448 new file mode 100644 index 0000000000000000000000000000000000000000..bcfb825c57af1f27d5bb1e63a3125f5ebec3793d GIT binary patch literal 3492 zcmeHJYiv|i5dO|RcOSi$vW2#Ei@>E#QP9@i?Ykwh6lkheTiUu&BGJuu0n^8}+Xp2! zP}(4nZMRe~8bYK$On{PF4W>TOr1dv35o3ahe?%e;YC;00J_^@4d++w4-HN6@5}jnu zeCKiJ%sDe>=2q0yR3PRAlFr4vRqywD5Ft4XtVY*FGBq*L*J|x4T4_fltti3H~n0VQyu$Bxkdj2T#_tsTG>`gTQ}= z*Z#rp$THikeUi@EM?hX}4Yc`y?Q@CF>JkUG(MKM9A8`oXV6zGph*b;YXbR%k){@dD zC!Jio9vhxXf4Ln!IEs@vgSRn;i@1!dxPd8VWeH4W53+o=^*|+4?91)z?Jj#wo=f_` z+dk9UYwZW^gZ6Rz75g_SNhxbm9!+UU;S+p9ShQF)l}vsj5_%~J;EZ1zFEEXJ+r>4_ zx!$~N>0>fcZ`m<+hP}@|W#38`NtFtv$E7;yMd?-P4e6uRpGnubjpy*dXImE0ir$gjvF^5^oTX_d)gD#wS*$NGK>R^m6F( zSprsICDtGf_u&CN1Q+&TBQ~Q9kD(H7JVTz_g$4w0R6C$`YJ0UH25^!M;xvYF9`BKF zE-;pMb|@I^vn8rZudVM$C{;1{*-X6~L#mRl918}6A>tn5mxx~=b}1%R>9?8s4-NF% zRONmpn69YGfX(D}kt9vWyHAk1*Se2)lFcd!{hkl?AMCZ6sY{cE%4AaKCMEQ`rG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ItrY{Y@(Fr6Mcb~xvUWnW^ zhB}Boe2c(~yTPh%j5%vq=aq0DBoaJ1fNSQq;{Y?V0B-N=obBpxXVdd;NQ9S#9S;CR zH9=KqrM!t>QwinZw%E#Hs>Mcw2Oq>b8FBq_9rXGH2-;x7@Yaeex^FACT#vWHaFxxf zofQ)|T(J$cMR0tGgrYC)I|QobkOAv(i(x{JhQ;})#UVB}E;d#}Gn_`lX?)b;z;S-Q zQXz*86B(WMe@N-mS*FJ?rjYZptlV9jr=4#)4dVX|$(<~$fw94^7yzFTE+j5CEL=)S zLPA+q%4sMG$Hfsm9BEh_r{UBLIsesMPgyM|&oAJVb}z!r4)!$olVQ@SRn{t*6?15| zR?c{ Date: Tue, 14 Apr 2026 21:19:43 -0600 Subject: [PATCH 2/8] [gpu] Cap accumulated curves per glyph to bound memory The curve accumulator grew without bound, reaching 2.9 GB on fuzzer-crafted inputs (VARC components expanded recursively, or cu2qu subdivisions on degenerate cubics, or a glyf with absurd contour counts). libFuzzer flags this as OOM. Add HB_GPU_DRAW_MAX_CURVES = 0x10000 (65536) -- far above any real glyph's needs -- and refuse to emit beyond it, flipping success=false so the encoder returns a valid empty/failure blob. Catches all upstream explosions (glyf / cu2qu / VARC / any future source) at the single choke point. Found by oss-fuzz/CIFuzz on hb-gpu-fuzzer. Assisted-by: Claude --- src/hb-gpu-draw.cc | 6 ++++++ src/hb-limits.hh | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/hb-gpu-draw.cc b/src/hb-gpu-draw.cc index c210230dd..03a29832d 100644 --- a/src/hb-gpu-draw.cc +++ b/src/hb-gpu-draw.cc @@ -52,6 +52,12 @@ acc_emit (hb_gpu_draw_t *g, double p2x, double p2y, double p3x, double p3y) { + if (unlikely (g->num_curves >= HB_GPU_DRAW_MAX_CURVES)) + { + g->success = false; + return; + } + hb_gpu_curve_t c = {p1x, p1y, p2x, p2y, p3x, p3y, contour_start}; if (unlikely (!g->curves.push_or_fail (c))) { diff --git a/src/hb-limits.hh b/src/hb-limits.hh index f5f6073e9..9d6c7ec68 100644 --- a/src/hb-limits.hh +++ b/src/hb-limits.hh @@ -112,6 +112,10 @@ #define HB_SVG_MAX_PATH_SEGMENTS 262144 #endif +#ifndef HB_GPU_DRAW_MAX_CURVES +#define HB_GPU_DRAW_MAX_CURVES 65536 +#endif + #ifndef HB_SVG_MAX_DOCUMENT_SIZE #define HB_SVG_MAX_DOCUMENT_SIZE ((size_t) 16 << 20) #endif From df4be0cec8e4a820fda8ae57e057e648c89822d1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 14 Apr 2026 21:49:12 -0600 Subject: [PATCH 3/8] [gpu] Use vector.reset() not resize(0) in hb_gpu_paint_clear Three accumulator vectors -- ops, sub_blobs, transform_stack -- can enter error state via failed push_or_fail() under failing-malloc. Once in error state, resize(0) short-circuits at the in_error() guard in alloc() and leaves length unchanged. In hb_gpu_paint_clear that means the next iteration's clear walks the stale entries again. For sub_blobs this is a double-destroy: the blob pointers were already freed in the previous clear, and hb_blob_destroy reads the dead ref_count field -- heap-use-after-free. Fix by calling vector.reset(), which clears the error state before resizing to 0. Matches the pattern hb_gpu_draw_clear already uses for draw->curves. Found by oss-fuzz/CIFuzz on hb-gpu-fuzzer; minimized testcase added to the fuzz corpus. Assisted-by: Claude --- src/hb-gpu-paint.cc | 11 ++++++++--- ...zer-7148eb19cc1a927d3bb5773630d4d9829fae5fbc | Bin 0 -> 14347 bytes 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-gpu-fuzzer-7148eb19cc1a927d3bb5773630d4d9829fae5fbc diff --git a/src/hb-gpu-paint.cc b/src/hb-gpu-paint.cc index 8aa3f1529..ff8bc94aa 100644 --- a/src/hb-gpu-paint.cc +++ b/src/hb-gpu-paint.cc @@ -1441,15 +1441,20 @@ hb_gpu_paint_encode (hb_gpu_paint_t *paint, void hb_gpu_paint_clear (hb_gpu_paint_t *paint) { - paint->ops.resize (0); + /* Use reset() not resize(0): if an earlier push_or_fail() set + * the vector's error state (common under failing-malloc), + * resize(0) short-circuits without clearing length. A + * subsequent clear would double-destroy the blob pointers left + * in the array, or keep stale ops across encodes. */ + paint->ops.reset (); paint->num_ops = 0; for (hb_blob_t *b : paint->sub_blobs) hb_blob_destroy (b); - paint->sub_blobs.resize (0); + paint->sub_blobs.reset (); paint->clip_depth = 0; paint->unsupported = false; paint->cur_transform = {1, 0, 0, 1, 0, 0}; - paint->transform_stack.resize (0); + paint->transform_stack.reset (); paint->ext_min_x = 0x7fffffff; paint->ext_min_y = 0x7fffffff; paint->ext_max_x = -0x7fffffff; diff --git a/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-gpu-fuzzer-7148eb19cc1a927d3bb5773630d4d9829fae5fbc b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-gpu-fuzzer-7148eb19cc1a927d3bb5773630d4d9829fae5fbc new file mode 100644 index 0000000000000000000000000000000000000000..e4c214bc65f9c34dbb934241cdd3a3a7c56cf258 GIT binary patch literal 14347 zcmeHO3viXi6+Zv-CimXlgyiN)NPaHik_7VLk_SkTBqR_q5K16WwLl1gh=ha?5p`;# zsH13Kz-WDpr8?75>vTGF(6j?>Mu!>gSVe|br0T#7YD8KTga9V_`^X8V$y$^{W1K&5RsCXtt zfs&*Nz!PT8D=UBct*5sjJq&ngr}?up@Q)&WKm6pf@(kZSn;!j=NInF7S^0v31yBFs z@!d#&5_nQoZDl<<=_#Zq1J7Eyp|aumx1M+h^}h^!-KsVBu6)TcHymLX#e{BNh4k!_ z#eXNV-9e=9s;RDA5%JX#B+I}lrv?$u54F`O|4+b^YHAxdE?ccMA$=S0*=y>mDko$l z-;MNkN+qhT+*nV~%OSu^k#4N5tgRmHyt#!)Lw@Pi`nvUvW-~z^(i%=DAuFO-AbyZ^ zi4>9`65nKB?&Rz#J~x>ZO8=uEP|K7+Iw)7bslXL0m${Q}w?bfoA=2_dAt9d(%x%S( z9lKvCE|pMkc}d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LS_@iI{X7&i?7R(ZEXZJ2($NV zYT>t(vq5gPLdok=I$psr^@;623!yYP=#=@;5lG1i_OPyqzivEaos+d^wMm%JV=Z5K z5gE_%|70|rhu|p>Qfl2^S~eS)SR6{`lp83^Fx#yaz|kCh+K?pENVaOsMQsI866>G< zRU=$Z_d?}qM7S2dLAOBl;mO}X__v8rxj1bFQj&$*)`<9YY<|kWIbF1ZSa>i6Q!?3s)7HHRHAP1V#M@ReT-PBOV&{op7|bMbXYJb z(+9|^>(^fkm9F}T0m%GYw2Hs7Nu4WT*ks%Lf05GfX8-^I literal 0 HcmV?d00001 From fe04146acb3c643c9e02a1ebbe0416442358c59b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 14 Apr 2026 22:00:32 -0600 Subject: [PATCH 4/8] [vector] Simplify reset() to use clear() instead of resize(0) After the March refactor that made clear() a direct shrink_vector(0), reset() going through resize(0) adds an indirection (resize_full -> alloc(0) no-op -> shrink_vector(0)) for identical observable behavior. Use clear() directly. Assisted-by: Claude --- src/hb-vector.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 600d78c13..e831c72b4 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -182,7 +182,7 @@ struct hb_vector_t { if (unlikely (in_error ())) reset_error (); - resize (0); + clear (); return *this; } From 2adb01a47cfec4f9dd902956820d4f9a800b736c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 14 Apr 2026 22:04:57 -0600 Subject: [PATCH 5/8] [internal] Replace remaining vector resize(0) with clear() Two callers were still using vector.resize(0) to drop accumulated data: graph/serialize.hh's overflow tracking and hb_bit_set_t's clear() (via its own internal resize()). resize(0) on a vector in error state short-circuits without zeroing length, leaving stale entries that downstream code then walks as if valid. Fix both: - serialize.hh: call overflows->clear() instead. - hb-bit-set.hh: reimplement clear() to zero length/population unconditionally by calling pages.clear() / page_map.clear() directly, bypassing the internal resize() that bails when `successful` is false. Mirrors the March clear() fix in hb-vector.hh (commit d134f88824). Assisted-by: Claude --- src/graph/serialize.hh | 2 +- src/hb-bit-set.hh | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/graph/serialize.hh b/src/graph/serialize.hh index 37fac8909..4f89f1011 100644 --- a/src/graph/serialize.hh +++ b/src/graph/serialize.hh @@ -108,7 +108,7 @@ inline bool will_overflow (graph_t& graph, hb_vector_t* overflows = nullptr) { - if (overflows) overflows->resize (0); + if (overflows) overflows->clear (); graph.update_positions (); hb_hashmap_t record_set; diff --git a/src/hb-bit-set.hh b/src/hb-bit-set.hh index 05725048c..0d612438d 100644 --- a/src/hb-bit-set.hh +++ b/src/hb-bit-set.hh @@ -117,9 +117,11 @@ struct hb_bit_set_t void clear () { - resize (0); - if (likely (successful)) - population = 0; + /* Always zero length and population, even when in error state, + * so a stale set can't leak pages into a subsequent reuse. */ + pages.clear (); + page_map.clear (); + population = 0; } bool is_empty () const { From 32fbe980ad81342d9962787ace961a09bd66ddc6 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 14 Apr 2026 22:08:06 -0600 Subject: [PATCH 6/8] [NEWS] Attribution --- NEWS | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 550701f3c..5137a5f32 100644 --- a/NEWS +++ b/NEWS @@ -2,14 +2,16 @@ Overview of changes leading to NEXT (REPLACEME) ===================================== - GPU library: - * New color-glyph paint renderer. hb_gpu_paint_t walks a font's - paint tree (COLRv0 or COLRv1) and encodes its layers -- solid - fills, linear / radial / sweep gradients, transforms, composite - groups -- into a compact blob. A new fragment-shader function - hb_gpu_paint() renders the blob in premultiplied RGBA; - monochrome glyphs are handled transparently via a synthesized - foreground-colored layer. Shader sources provided in GLSL, - WGSL, MSL, and HLSL. + + * New color-glyph paint renderer, based on design by LĂȘ Duy Quang. + hb_gpu_paint_t walks a font's paint tree (COLRv0 or COLRv1) and + encodes its layers -- solid fills, linear / radial / sweep + gradients, transforms, composite groups -- into a compact blob. + A new fragment-shader function hb_gpu_paint() renders the blob + in premultiplied RGBA; monochrome glyphs are handled + transparently via a synthesized foreground-colored layer. + Shader sources provided in GLSL, WGSL, MSL, and HLSL. + * Paint encoder limitations: the encoder sets `unsupported` and returns NULL when `num_ops` would exceed 32767, `push_group` nests deeper than 4, or the paint tree calls back through the From 8e7e29a691b262a8d83900c128eaf3404541e312 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 14 Apr 2026 22:11:04 -0600 Subject: [PATCH 7/8] [bit-set] Revert clear() change -- can't touch Null singleton The prior commit (2adb01a47c) made hb_bit_set_t::clear() always zero length/population, parallel to the hb_vector_t::clear() March fix. But hb_bit_set_t (and hb_hashmap_t) have a different invariant: an instance returned from a failed create-or-reference path is an inert / Null singleton in possibly read-only storage, so clear() MUST bail on !successful or it would segfault. This was exactly what the `if (unlikely (!successful)) return;` guard was protecting. test-set caught the regression. Vector is different: it has no Null singleton returned to users, so always-clearing is safe there. The graph/serialize.hh resize(0) -> clear() change from the same commit is still correct -- that's a caller-supplied vector, not a set. Assisted-by: Claude --- src/hb-bit-set.hh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/hb-bit-set.hh b/src/hb-bit-set.hh index 0d612438d..05725048c 100644 --- a/src/hb-bit-set.hh +++ b/src/hb-bit-set.hh @@ -117,11 +117,9 @@ struct hb_bit_set_t void clear () { - /* Always zero length and population, even when in error state, - * so a stale set can't leak pages into a subsequent reuse. */ - pages.clear (); - page_map.clear (); - population = 0; + resize (0); + if (likely (successful)) + population = 0; } bool is_empty () const { From d529a3ca9042a22a228e636a4c29920cb3692527 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 14 Apr 2026 22:13:42 -0600 Subject: [PATCH 8/8] [bit-set][hashmap] clear() under error state: early-out on empty Previously clear() bailed outright under !successful, to protect the Null singleton which lives in (possibly read-only) static storage. That meant a real instance entering error state would silently fail to clear, leaving stale contents for the next caller. Replace the `!successful` guard with an early-out on already- empty state. The Null singleton is zero-initialized (population, occupancy, mask all 0), so the early-out catches it before any write. Any non-empty instance is by construction a real heap object with writable storage, so clearing is safe there even under !successful. Assisted-by: Claude --- src/hb-bit-set.hh | 12 +++++++++--- src/hb-map.hh | 6 +++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/hb-bit-set.hh b/src/hb-bit-set.hh index 05725048c..7525e5a57 100644 --- a/src/hb-bit-set.hh +++ b/src/hb-bit-set.hh @@ -117,9 +117,15 @@ struct hb_bit_set_t void clear () { - resize (0); - if (likely (successful)) - population = 0; + /* Early-out on already-empty. Protects the Null singleton + * (which is zero-initialized) from any writes. Any non-empty + * instance is a real heap object with writable storage, so + * clearing through the vector's always-safe clear() is fine + * even if we entered error state. */ + if (!pages.length && !population) return; + pages.clear (); + page_map.clear (); + population = 0; } bool is_empty () const { diff --git a/src/hb-map.hh b/src/hb-map.hh index fefdbb19d..37cc2460b 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -379,7 +379,11 @@ struct hb_hashmap_t void clear () { - if (unlikely (!successful)) return; + /* Early-out on already-empty. Protects the Null singleton + * (zero-initialized) from any writes. Any non-empty hashmap + * is a real heap instance with writable items, so clearing + * under !successful is safe. */ + if (!population && !occupancy) return; for (auto &_ : hb_iter (items, size ())) {