From cf49f3f2cbec8fbdc654d45e2f4b8e9c8d91db47 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 3 Nov 2023 18:20:14 -0600 Subject: [PATCH] [sanitize] Add barrier() --- src/hb-ot-layout-common.hh | 2 ++ src/hb-sanitize.hh | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index bc3c12cf2..b73b62695 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -3716,6 +3716,7 @@ struct FeatureTableSubstitution { TRACE_SANITIZE (this); return_trace (version.sanitize (c) && + c->barrier () && likely (version.major == 1) && substitutions.sanitize (c, this)); } @@ -3909,6 +3910,7 @@ struct FeatureVariations { TRACE_SANITIZE (this); return_trace (version.sanitize (c) && + c->barrier () && likely (version.major == 1) && varRecords.sanitize (c, this)); } diff --git a/src/hb-sanitize.hh b/src/hb-sanitize.hh index 03277d1ad..d721d6e2c 100644 --- a/src/hb-sanitize.hh +++ b/src/hb-sanitize.hh @@ -134,7 +134,7 @@ struct hb_sanitize_context_t : const char *get_name () { return "SANITIZE"; } template bool may_dispatch (const T *obj HB_UNUSED, const F *format) - { return format->sanitize (this); } + { return format->sanitize (this) && barrier (); } static return_t default_return_value () { return true; } static return_t no_dispatch_return_value () { return false; } bool stop_sublookup_iteration (const return_t r) const { return !r; } @@ -381,14 +381,18 @@ struct hb_sanitize_context_t : return result; } -#define check_struct(This) \ - check_struct_ (This) * 1 & (_hb_compiler_memory_r_barrier (), 1) + HB_ALWAYS_INLINE + bool barrier () + { + _hb_compiler_memory_r_barrier (); + return true; + } template #ifndef HB_OPTIMIZE_SIZE HB_ALWAYS_INLINE #endif - bool check_struct_ (const Type *obj) const + bool check_struct (const Type *obj) const { if (sizeof (uintptr_t) == sizeof (uint32_t)) return likely (this->check_range_fast (obj, obj->min_size));