Skip to content

Commit

Permalink
Ensure null-terminated result from strncpy()
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryce Harrington committed Sep 10, 2015
1 parent b353d1f commit 6f7a9b4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/cairo-scaled-font-subsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6f7a9b4

Please sign in to comment.