From 1e34852f074e9d8afdd6b63590ef0b22bb0bf174 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Sat, 11 Jun 2022 01:27:33 +0000 Subject: [PATCH] [subset] Fix undefined behaviour. Don't memcpy if there's nothing to copy. --- src/hb-ot-post-table-v2subset.hh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hb-ot-post-table-v2subset.hh b/src/hb-ot-post-table-v2subset.hh index 9d651cca8..3456c9883 100644 --- a/src/hb-ot-post-table-v2subset.hh +++ b/src/hb-ot-post-table-v2subset.hh @@ -61,7 +61,8 @@ HB_INTERNAL bool postV2Tail::serialize (hb_serialize_context_t *c, HBUINT8 *o = c->allocate_size (HBUINT8::static_size * (s.length + 1)); if (unlikely (!o)) return_trace (false); if (!c->check_assign (o[0], s.length, HB_SERIALIZE_ERROR_INT_OVERFLOW)) return_trace (false); - memcpy (o+1, s.arrayZ, HBUINT8::static_size * s.length); + if (s.length) + memcpy (o+1, s.arrayZ, HBUINT8::static_size * s.length); } return_trace (true);