Don't serialize null offsets in CPAL.

Fixes https://oss-fuzz.com/testcase-detail/5443213648330752
This commit is contained in:
Garret Rieger 2021-08-18 14:20:14 -07:00 committed by Behdad Esfahbod
parent e29f56354a
commit dc31920bbe
2 changed files with 8 additions and 3 deletions

View File

@ -83,8 +83,13 @@ struct CPALV1Tail
auto *out = c->allocate_size<CPALV1Tail> (static_size); auto *out = c->allocate_size<CPALV1Tail> (static_size);
if (unlikely (!out)) return_trace (false); if (unlikely (!out)) return_trace (false);
out->paletteFlagsZ.serialize_copy (c, paletteFlagsZ, base, 0, hb_serialize_context_t::Head, palette_count); out->paletteFlagsZ = 0;
out->paletteLabelsZ.serialize_copy (c, paletteLabelsZ, base, 0, hb_serialize_context_t::Head, palette_count); if (paletteFlagsZ)
out->paletteFlagsZ.serialize_copy (c, paletteFlagsZ, base, 0, hb_serialize_context_t::Head, palette_count);
out->paletteLabelsZ = 0;
if (paletteLabelsZ)
out->paletteLabelsZ.serialize_copy (c, paletteLabelsZ, base, 0, hb_serialize_context_t::Head, palette_count);
const hb_array_t<const NameID> colorLabels = (base+colorLabelsZ).as_array (color_count); const hb_array_t<const NameID> colorLabels = (base+colorLabelsZ).as_array (color_count);
if (colorLabelsZ) if (colorLabelsZ)