From 253ec08b3db433f07175f21f90555657a9ce55f3 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 8 Jul 2023 12:48:05 -0600 Subject: [PATCH] [sanitize] Speed up check_struct on x64 --- src/hb-sanitize.hh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hb-sanitize.hh b/src/hb-sanitize.hh index 42945996e..2d338c51c 100644 --- a/src/hb-sanitize.hh +++ b/src/hb-sanitize.hh @@ -382,7 +382,12 @@ struct hb_sanitize_context_t : template bool check_struct (const Type *obj) const - { return likely (this->check_range_fast (obj, obj->min_size)); } + { + if (sizeof (uintptr_t) == sizeof (uint32_t)) + return likely (this->check_range_fast (obj, obj->min_size)); + else + return likely (this->check_point ((const char *) obj + obj->min_size)); + } bool may_edit (const void *base, unsigned int len) {