[cairo-commit] src/cairo-scaled-font-subsets.c

Bryce Harrington bryce at kemper.freedesktop.org
Thu Sep 10 11:19:08 PDT 2015


 src/cairo-scaled-font-subsets.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit 6f7a9b4f0375cdadf08486e4b877ee2afc176b39
Author: Bryce Harrington <bryce at osg.samsung.com>
Date:   Fri Aug 28 13:23:45 2015 -0700

    Ensure null-terminated result from strncpy()

diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index 2121761..196fa99 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -1206,10 +1206,12 @@ _cairo_scaled_font_subset_create_glyph_names (cairo_scaled_font_subset_t *subset
 
 	if (utf16_len == 1) {
 	    int ch = _cairo_unicode_to_winansi (utf16[0]);
-	    if (ch > 0 && _cairo_winansi_to_glyphname (ch))
+	    if (ch > 0 && _cairo_winansi_to_glyphname (ch)) {
 		strncpy (buf, _cairo_winansi_to_glyphname (ch), sizeof (buf));
-	    else
+		buf[sizeof (buf)-1] = '\0';
+	    } else {
 		snprintf (buf, sizeof (buf), "uni%04X", (int) utf16[0]);
+	    }
 
 	    _cairo_string_init_key (&key, buf);
 	    entry = _cairo_hash_table_lookup (names, &key.base);


More information about the cairo-commit mailing list