diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index f70084b2f..0b5b22737 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -38,8 +38,8 @@ */ #define HB_OT_TAG_COLR HB_TAG('C','O','L','R') -#ifndef COLRV1_MAX_NESTING_LEVEL -#define COLRV1_MAX_NESTING_LEVEL 100 +#ifndef HB_COLRV1_MAX_NESTING_LEVEL +#define HB_COLRV1_MAX_NESTING_LEVEL 100 #endif #ifndef COLRV1_ENABLE_SUBSETTING @@ -102,7 +102,7 @@ struct hb_colrv1_closure_context_t : hb_set_t *glyphs_, hb_set_t *layer_indices_, hb_set_t *palette_indices_, - unsigned nesting_level_left_ = COLRV1_MAX_NESTING_LEVEL) : + unsigned nesting_level_left_ = HB_COLRV1_MAX_NESTING_LEVEL) : base (base_), glyphs (glyphs_), layer_indices (layer_indices_), @@ -1068,7 +1068,8 @@ struct Paint { TRACE_SANITIZE (this); if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); - if (unlikely (!c->check_start_recursion ())) return_trace (c->no_dispatch_return_value ()); + if (unlikely (!c->check_start_recursion (HB_COLRV1_MAX_NESTING_LEVEL))) + return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (c->end_recursion (c->dispatch (u.paintformat1, std::forward (ds)...))); @@ -1103,7 +1104,7 @@ struct Paint case 30: return_trace (c->end_recursion (c->dispatch (u.paintformat30, std::forward (ds)...))); case 31: return_trace (c->end_recursion (c->dispatch (u.paintformat31, std::forward (ds)...))); case 32: return_trace (c->end_recursion (c->dispatch (u.paintformat32, std::forward (ds)...))); - default:return_trace (c->end_recursion (c->default_return_value ())); + default:return_trace (c->end_recursion (c->default_return_value ())); } } diff --git a/src/hb-sanitize.hh b/src/hb-sanitize.hh index faeb2aa49..65c277220 100644 --- a/src/hb-sanitize.hh +++ b/src/hb-sanitize.hh @@ -116,9 +116,6 @@ #ifndef HB_SANITIZE_MAX_SUBTABLES #define HB_SANITIZE_MAX_SUBTABLES 0x4000 #endif -#ifndef HB_SANITIZE_MAX_DEPTH -#define HB_SANITIZE_MAX_DEPTH 2500 -#endif struct hb_sanitize_context_t : hb_dispatch_context_t @@ -283,9 +280,9 @@ struct hb_sanitize_context_t : return this->check_range (base, a, b, hb_static_size (T)); } - bool check_start_recursion () + bool check_start_recursion (int max_depth) { - if (unlikely (recursion_depth >= HB_SANITIZE_MAX_DEPTH)) return false; + if (unlikely (recursion_depth >= max_depth)) return false; return ++recursion_depth; }