diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-12-19 09:46:31 -0800 |
---|---|---|
committer | Ulrich Sibiller <uli42@gmx.de> | 2016-10-19 21:40:30 +0200 |
commit | c00196d2d178b4ed1866c18ccab76cbb941df6f0 (patch) | |
tree | b9f0460a9c5eed27154404c61a63b96cd6fb0be7 | |
parent | f7254c69f00eb41fd3b8a78c6ae5d09fcfe1c01a (diff) | |
download | nx-libs-c00196d2d178b4ed1866c18ccab76cbb941df6f0.tar.gz nx-libs-c00196d2d178b4ed1866c18ccab76cbb941df6f0.tar.bz2 nx-libs-c00196d2d178b4ed1866c18ccab76cbb941df6f0.zip |
XDefaultOMIF: replace strlen+Xmalloc+strcpy with strdup
Code seems to have been originally written to handle appending multiple
strings, but only ever operates on a single string.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
-rw-r--r-- | nx-X11/lib/X11/XDefaultOMIF.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/nx-X11/lib/X11/XDefaultOMIF.c b/nx-X11/lib/X11/XDefaultOMIF.c index f9469feca..f7b1b1d8c 100644 --- a/nx-X11/lib/X11/XDefaultOMIF.c +++ b/nx-X11/lib/X11/XDefaultOMIF.c @@ -237,13 +237,12 @@ init_core_part( FontSet font_set; XFontStruct **font_struct_list; char **font_name_list, *font_name_buf; - int count, length; + int count; font_set = gen->font_set; - count = length = 0; + count = 0; if (font_set->font_name != NULL) { - length += strlen(font_set->font_name) + 1; count++; } if (count == 0) @@ -257,7 +256,7 @@ init_core_part( if (font_name_list == NULL) goto err; - font_name_buf = Xmalloc(length); + font_name_buf = strdup(font_set->font_name); if (font_name_buf == NULL) goto err; @@ -273,7 +272,6 @@ init_core_part( *font_struct_list++ = font_set->font; else *font_struct_list++ = font_set->info; - strcpy(font_name_buf, font_set->font_name); Xfree(font_set->font_name); *font_name_list++ = font_set->font_name = font_name_buf; font_name_buf += strlen(font_name_buf) + 1; @@ -482,13 +480,12 @@ set_missing_list( XOCGenericPart *gen = XOC_GENERIC(oc); FontSet font_set; char **charset_list, *charset_buf; - int count, length; + int count; font_set = gen->font_set; - count = length = 0; + count = 0; if (!font_set->info && !font_set->font) { - length += strlen(font_set->font_data->name) + 1; count++; } @@ -499,7 +496,7 @@ set_missing_list( if (charset_list == NULL) return False; - charset_buf = Xmalloc(length); + charset_buf = strdup(font_set->font_data->name); if (charset_buf == NULL) { Xfree(charset_list); return False; @@ -510,7 +507,6 @@ set_missing_list( font_set = gen->font_set; if (!font_set->info && !font_set->font) { - strcpy(charset_buf, font_set->font_data->name); *charset_list++ = charset_buf; charset_buf += strlen(charset_buf) + 1; } @@ -1058,7 +1054,7 @@ init_om( char **required_list; XOrientation *orientation; char *bufptr; - int i, count, length = 0; + int i, count; count = XlcNumber(supported_charset_list); @@ -1078,14 +1074,12 @@ init_om( return False; } - length += strlen(data->font_data->name) + 1; - /* required charset list */ required_list = Xmalloc(sizeof(char *)); if (required_list == NULL) return False; - bufptr = Xmalloc(length); + bufptr = strdup(data->font_data->name); if (bufptr == NULL) { Xfree(required_list); return False; @@ -1096,7 +1090,6 @@ init_om( data = gen->data; - strcpy(bufptr, data->font_data->name); *required_list++ = bufptr; bufptr += strlen(bufptr) + 1; |