*cmdname is initialized to NULL earlier in the function, so it's
okay to overwrite it with NULL if strdup fails, don't need that
extra check.

Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com>
---
 os/client.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/os/client.c b/os/client.c
index b534977..4aec097 100644
--- a/os/client.c
+++ b/os/client.c
@@ -149,13 +149,7 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, 
const char **cmdargs)
     cmdsize = strlen(path) + 1;
     if (cmdname)
     {
-        char *name = malloc(cmdsize);
-        if (name)
-        {
-            strncpy(name, path, cmdsize);
-            name[cmdsize - 1] = '\0';
-            *cmdname = name;
-        }
+        *cmdname = strdup(path);
     }
 
     /* Construct the arguments for client process. */
-- 
1.7.3.2

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to