Commit 22377a79 authored by Alan Coopersmith's avatar Alan Coopersmith Committed by Ulrich Sibiller

init_om: remove unneeded extra copy of string to local buffer

Strings from the supported_charset_list[] were being copied one by one to a stack buffer, and then strdup called on that buffer. Instead, just strdup the original string, without the local copy, and use a more traditional for loop, so it's easier to figure out what the code is doing (cleaning up a gcc const-cast warning in the process). Signed-off-by: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: 's avatarMatthieu Herrb <matthieu.herrb@laas.fr> Backported-to-NX-by: 's avatarUlrich Sibiller <uli42@gmx.de>
parent 92591316
...@@ -1148,10 +1148,9 @@ init_om( ...@@ -1148,10 +1148,9 @@ init_om(
FontData font_data; FontData font_data;
char **required_list; char **required_list;
XOrientation *orientation; XOrientation *orientation;
char **value, buf[BUFSIZ], *bufptr; char *bufptr;
int count, length = 0; int i, count, length = 0;
value = (char**)supported_charset_list;
count = XlcNumber(supported_charset_list); count = XlcNumber(supported_charset_list);
data = add_data(om); data = add_data(om);
...@@ -1164,14 +1163,8 @@ init_om( ...@@ -1164,14 +1163,8 @@ init_om(
data->font_data = font_data; data->font_data = font_data;
data->font_data_count = count; data->font_data_count = count;
for ( ; count-- > 0; font_data++) { for (i = 0; i < count; i++, font_data++) {
/* font_data->name = strdup(supported_charset_list[i]);
1266793
This one is fine. *value points to one of the local strings in
supported_charset_list[].
*/
strcpy(buf, *value++);
font_data->name = strdup(buf);
if (font_data->name == NULL) if (font_data->name == NULL)
return False; return False;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment