[raster] Reject empty gradient stop lists

The raster gradient code assumed every color line had at least one stop.
Malformed COLR data can report an empty stop list, which then reaches
normalize_color_line() and evaluate_color_line() and reads stops[0].

Treat empty color lines as a failed gradient fetch so malformed inputs
render nothing instead of dereferencing past the stop array.

Tested:
- meson compile -C build hb-raster-fuzzer

Fixes: https://oss-fuzz.com/testcase-detail/5216672087867392
Assisted-by: OpenAI Codex
This commit is contained in:
Behdad Esfahbod committed 2026-03-14 13:19:29 -03:00
1 parent ef191e9b2c
commit cb0757aad9
2 files changed
+2

No files matched your search

+2
View File
@@ -849,6 +849,8 @@ get_color_stops (hb_raster_paint_t *c,
hb_color_stop_t **stops)
{
unsigned len = hb_color_line_get_color_stops (color_line, 0, nullptr, nullptr);
if (unlikely (!len))
return false;
if (len > *count)
{
if (unlikely (!c->scratch_color_stops.resize (len)))