Reinstante DEFINE_NULL_DATA
Seems like I messed up; buffer overrun got reported.
This commit is contained in:
parent
93bdf9b2df
commit
191c4edc54
|
@ -685,6 +685,7 @@ struct Tag : HBUINT32
|
|||
public:
|
||||
DEFINE_SIZE_STATIC (4);
|
||||
};
|
||||
DEFINE_NULL_DATA (OT, Tag, " ");
|
||||
|
||||
/* Glyph index number, same as uint16 (length = 16 bits) */
|
||||
typedef HBUINT16 GlyphID;
|
||||
|
@ -696,6 +697,7 @@ typedef HBUINT16 NameID;
|
|||
struct Index : HBUINT16 {
|
||||
static const unsigned int NOT_FOUND_INDEX = 0xFFFFu;
|
||||
};
|
||||
DEFINE_NULL_DATA (OT, Index, "\xff\xff");
|
||||
|
||||
/* Offset, Null offset = 0 */
|
||||
template <typename Type>
|
||||
|
|
|
@ -165,6 +165,7 @@ struct RangeRecord
|
|||
public:
|
||||
DEFINE_SIZE_STATIC (6);
|
||||
};
|
||||
DEFINE_NULL_DATA (OT, RangeRecord, "\000\001");
|
||||
|
||||
|
||||
struct IndexArray : ArrayOf<Index>
|
||||
|
@ -224,6 +225,7 @@ struct LangSys
|
|||
public:
|
||||
DEFINE_SIZE_ARRAY (6, featureIndex);
|
||||
};
|
||||
DEFINE_NULL_DATA (OT, LangSys, "\0\0\xFF\xFF");
|
||||
|
||||
|
||||
struct Script
|
||||
|
@ -245,16 +247,7 @@ struct Script
|
|||
{ return langSys.find_index (tag, index); }
|
||||
|
||||
inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; }
|
||||
inline const LangSys& get_default_lang_sys (void) const
|
||||
{
|
||||
if (!defaultLangSys)
|
||||
{
|
||||
/* This is the ONLY place where our null data is not all zeros.
|
||||
* So, return special data instead of using the null pool. */
|
||||
return *reinterpret_cast<const LangSys *> ("\0\0\xFF\xFF");
|
||||
}
|
||||
return this+defaultLangSys;
|
||||
}
|
||||
inline const LangSys& get_default_lang_sys (void) const { return this+defaultLangSys; }
|
||||
|
||||
inline bool sanitize (hb_sanitize_context_t *c,
|
||||
const Record<Script>::sanitize_closure_t * = nullptr) const
|
||||
|
|
|
@ -1117,5 +1117,18 @@ static inline const Type& Null (void) {
|
|||
}
|
||||
#define Null(Type) Null<Type>()
|
||||
|
||||
/* Specializaiton for arbitrary-content arbitrary-sized Null objects. */
|
||||
#define DEFINE_NULL_DATA(Namespace, Type, data) \
|
||||
} /* Close namespace. */ \
|
||||
static const char _Null##Type[sizeof (Namespace::Type) + 1] = data; /* +1 is for nul-termination in data */ \
|
||||
template <> \
|
||||
/*static*/ inline const Namespace::Type& Null<Namespace::Type> (void) { \
|
||||
return *reinterpret_cast<const Namespace::Type *> (_Null##Type); \
|
||||
} \
|
||||
namespace Namespace { \
|
||||
/* The following line really exists such that we end in a place needing semicolon */ \
|
||||
static_assert (Namespace::Type::min_size + 1 <= sizeof (_Null##Type), "Null pool too small. Enlarge.")
|
||||
|
||||
|
||||
|
||||
#endif /* HB_PRIVATE_HH */
|
||||
|
|
Loading…
Reference in New Issue