[glyf] Clamp advance value result

Fixes a sanitizer complain https://circleci.com/gh/harfbuzz/harfbuzz/150247 revealed by 02d1ec1
This commit is contained in:
Ebrahim Byagowi 2020-08-06 23:37:43 +04:30 committed by GitHub
parent 02d1ec1658
commit 55c41f219f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -946,7 +946,7 @@ struct glyf
contour_point_t *get_phantoms_sink () { return phantoms; }
};
unsigned int
unsigned
get_advance_var (hb_font_t *font, hb_codepoint_t gid, bool is_vertical) const
{
bool success = false;
@ -960,9 +960,10 @@ struct glyf
? face->table.vmtx->get_advance (gid)
: face->table.hmtx->get_advance (gid);
return is_vertical
? roundf (phantoms[PHANTOM_TOP].y - phantoms[PHANTOM_BOTTOM].y)
: roundf (phantoms[PHANTOM_RIGHT].x - phantoms[PHANTOM_LEFT].x);
float result = is_vertical
? phantoms[PHANTOM_TOP].y - phantoms[PHANTOM_BOTTOM].y
: phantoms[PHANTOM_RIGHT].x - phantoms[PHANTOM_LEFT].x;
return hb_clamp (roundf (result), 0.f, (float) UINT_MAX / 2);
}
int get_side_bearing_var (hb_font_t *font, hb_codepoint_t gid, bool is_vertical) const