Commit a0e985fb authored by Ulrich Sibiller's avatar Ulrich Sibiller

Keystroke.c: replace calloc + 2 * strcpy by asprintf

parent 18547007
...@@ -324,13 +324,11 @@ void nxagentInitKeystrokes(Bool force) ...@@ -324,13 +324,11 @@ void nxagentInitKeystrokes(Bool force)
char *homedir = getenv("HOME"); char *homedir = getenv("HOME");
if (homedir) if (homedir)
{ {
if (!(homepath = calloc(1, strlen(homedir) + strlen(homefile) + 1))) if (-1 == asprintf(&homepath, "%s%s", homedir, homefile))
{ {
fprintf(stderr, "malloc failed"); fprintf(stderr, "malloc failed");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
strcpy(homepath, homedir);
strcpy(homepath + strlen(homedir), homefile);
} }
/* if any of the files can be read we have our candidate */ /* if any of the files can be read we have our candidate */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment