xserver: Branch 'server-1.11-branch'

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Wed Jan 18 10:51:27 PST 2012


 os/client.c |    8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

New commits:
commit d2db5100b1bafeeea8c1febd390631c8f8abb094
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Fri Oct 28 21:29:50 2011 -0700

    Convert DetermineClientCmd to use strdup instead of malloc+strncpy
    
    *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.coopersmith at oracle.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 780133f9ae7fada462714b47e79d26075bbd9abe)

diff --git a/os/client.c b/os/client.c
index aa9be84..fbccf22 100644
--- a/os/client.c
+++ b/os/client.c
@@ -234,13 +234,7 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
     /* Contruct the process name without arguments. */
     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. */


More information about the xorg-commit mailing list