[subset] clamp distance to prevent shifting outside of the limits of int64.

Fixes https://oss-fuzz.com/testcase-detail/4961171477233664.
This commit is contained in:
Garret Rieger 2021-04-05 12:03:17 -07:00 committed by Behdad Esfahbod
parent fcacd17748
commit 71d6d15600
2 changed files with 2 additions and 1 deletions

View File

@ -75,7 +75,8 @@ struct graph_t
// setting distance = 0 which will force to sort immediately after
// it's parent where possible.
int64_t modified_distance = distance + distance_modifier ();
int64_t modified_distance =
hb_min (hb_max(distance + distance_modifier (), 0), 0x7FFFFFFFFF);
return (modified_distance << 24) | (0x00FFFFFF & order);
}