Commit 18547007 authored by Ulrich Sibiller's avatar Ulrich Sibiller

Font.c: replace malloc + strcpy by strdup + fix memleak

parent 054ae844
......@@ -334,10 +334,12 @@ void nxagentListRemoteAddName(const char *name, int status)
if ((nxagentRemoteFontList.list[pos] = malloc(sizeof(nxagentFontRec))))
{
nxagentRemoteFontList.list[pos]->name = malloc(strlen(name) +1);
nxagentRemoteFontList.list[pos]->name = strdup(name);
if (nxagentRemoteFontList.list[pos]->name == NULL)
{
fprintf(stderr, "Font: remote list name memory allocation failed!.\n");
free(nxagentRemoteFontList.list[pos]);
nxagentRemoteFontList.list[pos] = NULL;
return;
}
}
......@@ -346,7 +348,6 @@ void nxagentListRemoteAddName(const char *name, int status)
fprintf(stderr, "Font: remote list record memory allocation failed!.\n");
return;
}
strcpy(nxagentRemoteFontList.list[pos]->name,name);
nxagentRemoteFontList.list[pos]->status = status;
nxagentRemoteFontList.length++;
......
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