[vector] Guard glyph-id parsing against overflow

This commit is contained in:
Behdad Esfahbod committed 2026-02-24 19:43:32 -03:00
1 parent d316c94abb
commit 2ef2ef0527
1 file changed
+6 -1
+6 -1
View File
@@ -375,7 +375,12 @@ hb_svg_parse_glyph_id_span (const hb_svg_id_span_t &id,
unsigned char c = (unsigned char) id.p[i];
if (c < '0' || c > '9')
return false;
gid = (hb_codepoint_t) (gid * 10 + (c - '0'));
hb_codepoint_t digit = (hb_codepoint_t) (c - '0');
if (unlikely (gid > HB_CODEPOINT_INVALID / 10 ||
(gid == HB_CODEPOINT_INVALID / 10 &&
digit > HB_CODEPOINT_INVALID % 10)))
return false;
gid = (hb_codepoint_t) (gid * 10 + digit);
}
*glyph = gid;