From 35d6af69435ff070cee00f7cd9741b3545ca161c Mon Sep 17 00:00:00 2001 From: Qunxin Liu Date: Fri, 4 Jun 2021 10:04:27 -0700 Subject: [PATCH] [subset] fix fuzzer testcase: https://oss-fuzz.com/testcase-detail/5965777994907648 --- src/hb-ot-color-colr-table.hh | 15 +++++++++++++-- ...e-minimized-hb-subset-fuzzer-5965777994907648 | Bin 0 -> 159 bytes 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5965777994907648 diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index 579366a36..b714f991f 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -37,6 +37,9 @@ */ #define HB_OT_TAG_COLR HB_TAG('C','O','L','R') +#ifndef COLRV1_MAX_NESTING_LEVEL +#define COLRV1_MAX_NESTING_LEVEL 100 +#endif namespace OT { @@ -47,10 +50,15 @@ struct hb_colrv1_closure_context_t : template return_t dispatch (const T &obj) { + if (unlikely (nesting_level_left == 0)) + return hb_empty_t (); + if (paint_visited (&obj)) return hb_empty_t (); + nesting_level_left--; obj.closurev1 (this); + nesting_level_left++; return hb_empty_t (); } static return_t default_return_value () { return hb_empty_t (); } @@ -83,15 +91,18 @@ struct hb_colrv1_closure_context_t : hb_set_t *glyphs; hb_set_t *layer_indices; hb_set_t *palette_indices; + unsigned nesting_level_left; hb_colrv1_closure_context_t (const void *base_, hb_set_t *glyphs_, hb_set_t *layer_indices_, - hb_set_t *palette_indices_) : + hb_set_t *palette_indices_, + unsigned nesting_level_left_ = COLRV1_MAX_NESTING_LEVEL) : base (base_), glyphs (glyphs_), layer_indices (layer_indices_), - palette_indices (palette_indices_) + palette_indices (palette_indices_), + nesting_level_left (nesting_level_left_) {} }; diff --git a/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5965777994907648 b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5965777994907648 new file mode 100644 index 0000000000000000000000000000000000000000..a302c1060404c97034773c858972390f2131c903 GIT binary patch literal 159 zcmZQzWME)my2P^nrS2_ff1e-*w*a63gEspM28P_kiULuFC#E32CVv