diff options
author | Ulrich Sibiller <uli42@gmx.de> | 2018-01-03 01:31:52 +0100 |
---|---|---|
committer | Ulrich Sibiller <uli42@gmx.de> | 2018-01-07 01:27:07 +0100 |
commit | 1854700722db8067460e82a711521fdb27fb51d4 (patch) | |
tree | fbf4b294cf1282aca568ed89ae6af38fe06fbf23 /nx-X11 | |
parent | 054ae844758a306df4aacd40c46780195853a8f8 (diff) | |
download | nx-libs-1854700722db8067460e82a711521fdb27fb51d4.tar.gz nx-libs-1854700722db8067460e82a711521fdb27fb51d4.tar.bz2 nx-libs-1854700722db8067460e82a711521fdb27fb51d4.zip |
Font.c: replace malloc + strcpy by strdup + fix memleak
Diffstat (limited to 'nx-X11')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Font.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c index 197f0c84a..5af88b137 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Font.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c @@ -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++; |