[X2Go-Commits] [nx-libs] 23/29: Font.c: replace malloc + strcpy by strdup + fix memleak

git-admin at x2go.org git-admin at x2go.org
Sun Jan 7 01:31:00 CET 2018


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch 3.6.x
in repository nx-libs.

commit 1854700722db8067460e82a711521fdb27fb51d4
Author: Ulrich Sibiller <uli42 at gmx.de>
Date:   Wed Jan 3 01:31:52 2018 +0100

    Font.c: replace malloc + strcpy by strdup + fix memleak
---
 nx-X11/programs/Xserver/hw/nxagent/Font.c | 5 +++--
 1 file 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 197f0c8..5af88b1 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++;
 

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git


More information about the x2go-commits mailing list