From b89b8094934856ae2f2b0e3bca83d3fe171f87b9 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 3 Jan 2018 02:34:10 +0100 Subject: Error.c: replace malloc+strcpy by strdup --- nx-X11/programs/Xserver/hw/nxagent/Error.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'nx-X11/programs/Xserver/hw/nxagent') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.c b/nx-X11/programs/Xserver/hw/nxagent/Error.c index 7abd83ae3..f5fb297b3 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Error.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c @@ -524,6 +524,7 @@ char *nxagentGetSessionPath(void) return NULL; } + /* FIXME: necessary? */ snprintf(nxagentSessionDir, DEFAULT_STRING_LENGTH, "%s", rootPath); if (strlen(nxagentSessionDir) + strlen("/C-") + strlen(nxagentSessionId) > DEFAULT_STRING_LENGTH - 1) @@ -562,9 +563,9 @@ char *nxagentGetSessionPath(void) } - sessionPath = malloc(strlen(nxagentSessionDir) + 1); + sessionPath = strdup(nxagentSessionDir); - if (sessionPath == NULL) + if (sessionPath == NULL) { #ifdef PANIC fprintf(stderr, "nxagentGetSessionPath:: PANIC! Can't allocate memory for the session path.\n"); @@ -573,9 +574,6 @@ char *nxagentGetSessionPath(void) return NULL; } - - strcpy(sessionPath, nxagentSessionDir); - return sessionPath; } -- cgit v1.2.3