[subset] Fix undefined behaviour.

Don't memcpy if there's nothing to copy.
This commit is contained in:
Garret Rieger authored and Behdad Esfahbod committed 2022-06-14 17:49:13 +01:00
1 parent 311413f16b
commit 1e34852f07
1 file changed
+2 -1
+2 -1
View File
@@ -61,7 +61,8 @@ HB_INTERNAL bool postV2Tail::serialize (hb_serialize_context_t *c,
HBUINT8 *o = c->allocate_size<HBUINT8> (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);