Merge pull request #5923 from harfbuzz/fuzzer-fixes-apr14

Fuzzer fixes apr14
This commit is contained in:
Behdad Esfahbod authored and GitHub committed 2026-04-14 22:35:08 -06:00
commit 041fffa45f
12 files changed
+48 -19

No files matched your search

+10 -8
View File
@@ -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
+1 -1
View File
@@ -108,7 +108,7 @@ inline bool
will_overflow (graph_t& graph,
hb_vector_t<overflow_record_t>* overflows = nullptr)
{
if (overflows) overflows->resize (0);
if (overflows) overflows->clear ();
graph.update_positions ();
hb_hashmap_t<overflow_record_t*, bool> record_set;
+9 -3
View File
@@ -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
{
+6
View File
@@ -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)))
{
+8 -3
View File
@@ -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;
+4
View File
@@ -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
+5 -1
View File
@@ -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 ()))
{
+4 -2
View File
@@ -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)
+1 -1
View File
@@ -182,7 +182,7 @@ struct hb_vector_t
{
if (unlikely (in_error ()))
reset_error ();
resize (0);
clear ();
return *this;
}