From a6065d05cf38620c06b6dd10b8a841ed236f76c2 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Wed, 10 Jul 2019 16:41:40 +0430 Subject: [PATCH] Don't call memcpy when a table is empty --- src/hb-open-file.hh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hb-open-file.hh b/src/hb-open-file.hh index 5318c7fc..f3f4dc07 100644 --- a/src/hb-open-file.hh +++ b/src/hb-open-file.hh @@ -141,14 +141,15 @@ typedef struct OffsetTable TableRecord &rec = tables.arrayZ[i]; hb_blob_t *blob = items[i].blob; rec.tag = items[i].tag; - rec.length = hb_blob_get_length (blob); + rec.length = blob->length; rec.offset.serialize (c, this); /* Allocate room for the table and copy it. */ char *start = (char *) c->allocate_size (rec.length); - if (unlikely (!start)) {return false;} + if (unlikely (!start)) return false; - memcpy (start, hb_blob_get_data (blob, nullptr), rec.length); + if (likely (rec.length)) + memcpy (start, blob->data, rec.length); /* 4-byte alignment. */ c->align (4); -- GitLab