mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-05-06 04:38:08 +02:00
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@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 780133f9ae)
This commit is contained in:
parent
5b28bcb340
commit
d2db5100b1
1 changed files with 1 additions and 7 deletions
|
|
@ -234,13 +234,7 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
|
||||||
/* Contruct the process name without arguments. */
|
/* Contruct the process name without arguments. */
|
||||||
if (cmdname)
|
if (cmdname)
|
||||||
{
|
{
|
||||||
char *name = malloc(cmdsize);
|
*cmdname = strdup(path);
|
||||||
if (name)
|
|
||||||
{
|
|
||||||
strncpy(name, path, cmdsize);
|
|
||||||
name[cmdsize - 1] = '\0';
|
|
||||||
*cmdname = name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Construct the arguments for client process. */
|
/* Construct the arguments for client process. */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue