From 4fbc2ea3869a5148529ee59161d78952b64bb697 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Wed, 8 Feb 2023 20:05:52 +1030 Subject: [PATCH] truetype: revert use of _cairo_strndup 3d102f25 changed the malloc/memcpy to _cairo_strndup but it won't work in this case as the string may be UTF-16. --- src/cairo-truetype-subset.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c index 91ee0e90b..78c7dd5ec 100644 --- a/src/cairo-truetype-subset.c +++ b/src/cairo-truetype-subset.c @@ -1471,10 +1471,14 @@ find_name (tt_name_t *name, unsigned long size, int name_id, int platform, int e if (offset + len > size) return _cairo_error (CAIRO_STATUS_NO_MEMORY); - str = _cairo_strndup (((char*)name) + offset, len); + str = _cairo_malloc (len + 1); if (str == NULL) return _cairo_error (CAIRO_STATUS_NO_MEMORY); + memcpy (str, + ((char*)name) + offset, + len); + str[len] = 0; break; } }