未验证 提交 79e7e344 编写于 作者: E Ebrahim Byagowi 提交者: GitHub

Merge pull request #1449 from harfbuzz/cff-fixcharset

[CFF] fix for oss-fuzz 11657: Charset overrun
......@@ -392,13 +392,15 @@ struct Charset1_2 {
return 0;
}
inline hb_codepoint_t get_glyph (hb_codepoint_t sid) const
inline hb_codepoint_t get_glyph (hb_codepoint_t sid, unsigned int num_glyphs) const
{
if (sid == 0) return 0;
hb_codepoint_t glyph = 1;
for (unsigned int i = 0;; i++)
{
if ((ranges[i].first <= sid) && sid <= ranges[i].first + ranges[i].nLeft)
if (glyph >= num_glyphs)
return 0;
if ((ranges[i].first <= sid) && (sid <= ranges[i].first + ranges[i].nLeft))
return glyph + (sid - ranges[i].first);
glyph += (ranges[i].nLeft + 1);
}
......@@ -550,9 +552,9 @@ struct Charset {
if (format == 0)
return u.format0.get_glyph (sid, num_glyphs);
else if (format == 1)
return u.format1.get_glyph (sid);
return u.format1.get_glyph (sid, num_glyphs);
else
return u.format2.get_glyph (sid);
return u.format2.get_glyph (sid, num_glyphs);
}
HBUINT8 format;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册