diff options
author | Adrian Johnson <ajohnson@redneon.com> | 2023-01-03 16:01:51 +1030 |
---|---|---|
committer | Adrian Johnson <ajohnson@redneon.com> | 2023-01-03 16:01:51 +1030 |
commit | 3d102f25c924936d660fb771b695f753debf8d44 (patch) | |
tree | 3eea1b9b16427d0826dc117536476b027c4d7435 /src/cairo-truetype-subset.c | |
parent | 6d03a186491b34745ae13a6a589799ab40fa699b (diff) | |
download | cairo-3d102f25c924936d660fb771b695f753debf8d44.tar.gz |
Use _cairo_strndup where appropriate
Diffstat (limited to 'src/cairo-truetype-subset.c')
-rw-r--r-- | src/cairo-truetype-subset.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c index c58b96665..91ee0e90b 100644 --- a/src/cairo-truetype-subset.c +++ b/src/cairo-truetype-subset.c @@ -1,3 +1,4 @@ +/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */ /* cairo - a vector graphics library with display and print output * * Copyright © 2004 Red Hat, Inc @@ -1470,14 +1471,10 @@ 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_malloc (len + 1); + str = _cairo_strndup (((char*)name) + offset, len); if (str == NULL) return _cairo_error (CAIRO_STATUS_NO_MEMORY); - memcpy (str, - ((char*)name) + offset, - len); - str[len] = 0; break; } } @@ -1531,13 +1528,7 @@ find_name (tt_name_t *name, unsigned long size, int name_id, int platform, int e } } if (has_tag) { - p = _cairo_malloc (len - 6); - if (unlikely (p == NULL)) { - status =_cairo_error (CAIRO_STATUS_NO_MEMORY); - goto fail; - } - memcpy (p, str + 7, len - 7); - p[len-7] = 0; + p = _cairo_strndup (str + 7, len - 7); free (str); str = p; } |