diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 090f3fc47..b337ab7b4 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -171,6 +171,10 @@ ASSERT_STATIC (Type::min_size + 1 <= sizeof (_Null##Type)) (&c->debug_depth, c->get_name (), this, HB_FUNC, \ ""); +/* This limits sanitizing time on really broken fonts. */ +#ifndef HB_SANITIZE_MAX_EDITS +#define HB_SANITIZE_MAX_EDITS 100 +#endif struct hb_sanitize_context_t { @@ -247,6 +251,9 @@ struct hb_sanitize_context_t inline bool may_edit (const void *base HB_UNUSED, unsigned int len HB_UNUSED) { + if (this->edit_count >= HB_SANITIZE_MAX_EDITS) + return false; + const char *p = (const char *) base; this->edit_count++;