From 1856184b93760a1a54fb1a3c54281bb252df7ce6 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 22 Apr 2010 14:15:11 -0400 Subject: [PATCH] Fail sanitize on major version mismatch We handle major-version differences via get_for_data(), so sanitize should never see a major version mismatch. --- src/hb-open-file-private.hh | 4 ++-- src/hb-ot-layout-gdef-private.hh | 2 +- src/hb-ot-layout-gsubgpos-private.hh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh index 91854f8..10de334 100644 --- a/src/hb-open-file-private.hh +++ b/src/hb-open-file-private.hh @@ -139,8 +139,8 @@ struct TTCHeader inline bool sanitize (SANITIZE_ARG_DEF) { TRACE_SANITIZE (); if (!SANITIZE (version)) return false; - if (version.major < 1 || version.major > 2) return true; - return table.sanitize (SANITIZE_ARG, CharP(this), CharP(this)); + if (HB_UNLIKELY (version.major < 1 || version.major > 2)) return false; + return HB_LIKELY (table.sanitize (SANITIZE_ARG, CharP(this), CharP(this))); } private: diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh index 4f6c1d9..4de5740 100644 --- a/src/hb-ot-layout-gdef-private.hh +++ b/src/hb-ot-layout-gdef-private.hh @@ -346,7 +346,7 @@ struct GDEF inline bool sanitize (SANITIZE_ARG_DEF) { TRACE_SANITIZE (); if (!SANITIZE (version)) return false; - if (version.major != 1) return true; + if (HB_UNLIKELY (version.major != 1)) return false; return SANITIZE_THIS2 (glyphClassDef, attachList) && SANITIZE_THIS2 (ligCaretList, markAttachClassDef) && (version < 0x00010002 || SANITIZE_THIS (markGlyphSetsDef[0])); diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index c5639bb..2856d34 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -937,7 +937,7 @@ struct GSUBGPOS inline bool sanitize (SANITIZE_ARG_DEF) { TRACE_SANITIZE (); if (!SANITIZE (version)) return false; - if (version.major != 1) return true; + if (HB_UNLIKELY (version.major != 1)) return false; return SANITIZE_THIS3 (scriptList, featureList, lookupList); } -- 2.7.4