From 347b94481100d2eefc88c1e6bc71aa20dcb907bb Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 26 Jun 2023 18:09:40 -0600 Subject: [PATCH] [null] Fix getting Crap(hb_bytes_t) Fixes https://oss-fuzz.com/testcase-detail/6187272924692480 --- src/hb-null.hh | 6 +++--- ...se-minimized-hb-subset-fuzzer-6187272924692480 | Bin 0 -> 609 bytes 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-6187272924692480 diff --git a/src/hb-null.hh b/src/hb-null.hh index 3da2d75ef..024089397 100644 --- a/src/hb-null.hh +++ b/src/hb-null.hh @@ -176,7 +176,7 @@ template static inline Type& Crap () { static_assert (hb_null_size (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE."); Type *obj = reinterpret_cast (_hb_CrapPool); - memcpy (obj, &Null (Type), sizeof (*obj)); + memcpy (obj, std::addressof (Null (Type)), sizeof (*obj)); return *obj; } template @@ -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 operator const C * () const { return get (); } operator const char * () const { return (const char *) get (); } - T * get () const { return v ? v : const_cast (&Null (T)); } + T * get () const { return v ? v : const_cast (std::addressof (Null (T))); } T * get_raw () const { return v; } private: diff --git a/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-6187272924692480 b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-6187272924692480 new file mode 100644 index 0000000000000000000000000000000000000000..db9f11bcbad952ca226b693fc6579e3aecfb4e0c GIT binary patch literal 609 zcmeYd3Grv(Q2+yHH#acNz`$??A_5`*!#M~RTnL51fWlKy_ypm@wKV|wK+b=-0Gj%3 zU_MMbH?g7sBmi{J8HfZ}Gnfe>{vxse1JwmEFfc19Fe