From e89df6e1aee9cb6fe1268643ce19816808baf0c4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 30 Jan 2018 10:58:44 -0800 Subject: [PATCH] [aat] Limit number of DontAdvance transitions Remove the faulty loop-detection logic. Use max-ops for breaking out of infinite loops or heavy work. https://twitter.com/behdadesfahbod/status/958065026262183936 --- src/hb-aat-layout-common-private.hh | 33 ++--------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/src/hb-aat-layout-common-private.hh b/src/hb-aat-layout-common-private.hh index d62bafc5..b5395bba 100644 --- a/src/hb-aat-layout-common-private.hh +++ b/src/hb-aat-layout-common-private.hh @@ -615,13 +615,7 @@ struct StateTableDriver machine (machine_), buffer (buffer_), num_glyphs (face_->get_num_glyphs ()), - last_zero (0), - dont_advance_set (nullptr) {} - - inline ~StateTableDriver (void) - { - hb_set_destroy (dont_advance_set); - } + last_zero (0) {} template inline void drive (context_t *c) @@ -648,27 +642,7 @@ struct StateTableDriver if (unlikely (!c->transition (this, entry))) break; - if (entry->flags & context_t::DontAdvance) - { - if (!last_was_dont_advance) - { - if (dont_advance_set) - dont_advance_set->clear (); - else - dont_advance_set = hb_set_create (); - } - - unsigned int key = info[buffer->idx].codepoint ^ (state << 16); - if (likely (!dont_advance_set->has (key))) - { - dont_advance_set->add (key); - last_was_dont_advance = true; - } - else - last_was_dont_advance = false; - } - else - last_was_dont_advance = false; + last_was_dont_advance = (entry->flags & context_t::DontAdvance) && buffer->max_ops--; state = entry->newState; @@ -692,9 +666,6 @@ struct StateTableDriver hb_buffer_t *buffer; unsigned int num_glyphs; unsigned int last_zero; - - private: - hb_set_t *dont_advance_set; /* Infinite-loop detection */ }; -- GitLab