From 6549aec89de04caf2546597fe6ebf3811944615d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 1 Aug 2022 13:11:14 -0600 Subject: [PATCH] [SingleSubstFormat1] Help avoid timeouts in closure() some more For https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=49712 --- src/OT/Layout/GSUB/SingleSubstFormat1.hh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/OT/Layout/GSUB/SingleSubstFormat1.hh b/src/OT/Layout/GSUB/SingleSubstFormat1.hh index 4b17243d8..13665d7ba 100644 --- a/src/OT/Layout/GSUB/SingleSubstFormat1.hh +++ b/src/OT/Layout/GSUB/SingleSubstFormat1.hh @@ -42,6 +42,11 @@ struct SingleSubstFormat1_3 hb_codepoint_t d = deltaGlyphID; hb_codepoint_t mask = get_mask (); + /* Help fuzzer avoid this function as much. */ + unsigned pop = (this+coverage).get_population (); + if (pop >= mask) + return; + hb_set_t intersection; (this+coverage).intersect_set (c->parent_active_glyphs (), intersection); @@ -52,7 +57,7 @@ struct SingleSubstFormat1_3 hb_codepoint_t max_before = intersection.get_max (); hb_codepoint_t min_after = (min_before + d) & mask; hb_codepoint_t max_after = (max_before + d) & mask; - if ((this+coverage).get_population () >= max_before - min_before && + if (pop >= max_before - min_before && ((min_before <= min_after && min_after <= max_before) || (min_before <= max_after && max_after <= max_before))) return;