diff options
author | Ebrahim Byagowi <ebrahim@gnu.org> | 2020-08-06 23:37:43 +0430 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-06 23:37:43 +0430 |
commit | 55c41f219f539464335c16dc8392787fd0ac1b46 (patch) | |
tree | 6820e5f62b1fb9c19e54e6e8814808ffd3fc4f16 /src | |
parent | 02d1ec16585738d5e55354224bcfcc552b079a76 (diff) | |
download | harfbuzz_ng-55c41f219f539464335c16dc8392787fd0ac1b46.tar.gz |
[glyf] Clamp advance value result
Fixes a sanitizer complain https://circleci.com/gh/harfbuzz/harfbuzz/150247 revealed by 02d1ec1
Diffstat (limited to 'src')
-rw-r--r-- | src/hb-ot-glyf-table.hh | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh index dc15ff1d6..f4691622a 100644 --- a/src/hb-ot-glyf-table.hh +++ b/src/hb-ot-glyf-table.hh @@ -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 |