From ffde3c9f9effcd2b47f5fd76df45551e68c0b1ec Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 8 Feb 2017 21:56:57 +0000 Subject: [PATCH] hb-font: Fix a potentially undefined use of memcmp() (#413) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While it’s fine to call memcmp(x, 0, 0) in practice, the C99 standard explicitly says that this is not allowed: even if the length is zero, the pointer arguments must be valid. http://stackoverflow.com/a/16363034 Coverity ID: 141178 Signed-off-by: Philip Withnall --- src/hb-font.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hb-font.cc b/src/hb-font.cc index a08766f5..e900bd3f 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -1596,7 +1596,8 @@ _hb_font_adopt_var_coords_normalized (hb_font_t *font, unsigned int coords_length) { if (font->num_coords == coords_length && - 0 == memcmp (font->coords, coords, coords_length * sizeof (coords[0]))) + (coords_length == 0 || + 0 == memcmp (font->coords, coords, coords_length * sizeof (coords[0])))) { free (coords); return; -- GitLab