[null] Fix getting Crap(hb_bytes_t)

Fixes https://oss-fuzz.com/testcase-detail/6187272924692480
This commit is contained in:
Behdad Esfahbod 2023-06-26 18:09:40 -06:00
parent 49c52fa953
commit 347b944811
2 changed files with 3 additions and 3 deletions

View file

@ -176,7 +176,7 @@ template <typename Type>
static inline Type& Crap () {
static_assert (hb_null_size (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
Type *obj = reinterpret_cast<Type *> (_hb_CrapPool);
memcpy (obj, &Null (Type), sizeof (*obj));
memcpy (obj, std::addressof (Null (Type)), sizeof (*obj));
return *obj;
}
template <typename QType>
@ -211,11 +211,11 @@ struct hb_nonnull_ptr_t
T * operator = (T *v_) { return v = v_; }
T * operator -> () const { return get (); }
T & operator * () const { return *get (); }
T ** operator & () const { return &v; }
T ** operator & () const { return std::addressof (v); }
/* Only auto-cast to const types. */
template <typename C> operator const C * () const { return get (); }
operator const char * () const { return (const char *) get (); }
T * get () const { return v ? v : const_cast<T *> (&Null (T)); }
T * get () const { return v ? v : const_cast<T *> (std::addressof (Null (T))); }
T * get_raw () const { return v; }
private: