Make sanitize() a const method This makes a lot of code safer. We only try modifying the object in one place, after making sure it's safe to do so. So, do a const_cast<> in that one place...
diff --git a/src/hb-ot-name-table.hh b/src/hb-ot-name-table.hh index 31d9fac..9faff08 100644 --- a/src/hb-ot-name-table.hh +++ b/src/hb-ot-name-table.hh
@@ -56,7 +56,8 @@ return 0; } - inline bool sanitize (hb_sanitize_context_t *c, void *base) { + inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + { TRACE_SANITIZE (this); /* We can check from base all the way up to the end of string... */ return TRACE_RETURN (c->check_struct (this) && c->check_range ((char *) base, (unsigned int) length + offset)); @@ -110,7 +111,8 @@ return TRACE_RETURN (true); } - inline bool sanitize (hb_sanitize_context_t *c) { + inline bool sanitize (hb_sanitize_context_t *c) const + { TRACE_SANITIZE (this); return TRACE_RETURN (c->check_struct (this) && likely (format == 0 || format == 1) &&