X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=fish%2Ftilde.c;h=806297c5ff8b9ce11a21ae92d4d546d37890aec6;hb=a9802509184341e731de5c9af363184a9964a8a7;hp=64b5b399f0e5546abb3bdfdf48f5f5421828bb20;hpb=3e70b34eed5a48640e20fbf6dcba774aaace1f3c;p=libguestfs.git diff --git a/fish/tilde.c b/fish/tilde.c index 64b5b39..806297c 100644 --- a/fish/tilde.c +++ b/fish/tilde.c @@ -58,11 +58,11 @@ try_tilde_expansion (char *str) home = find_home_for_username (&str[1], len); if (home) { - len = strlen (home) + strlen (rest); + len = strlen (home) + strlen (rest) + 1; str = malloc (len); if (str == NULL) { perror ("malloc"); - exit (1); + exit (EXIT_FAILURE); } strcpy (str, home); strcat (str, rest); @@ -85,11 +85,11 @@ expand_home (const char *append) home = getenv ("HOME"); if (!home) home = "~"; - len = strlen (home) + (append ? strlen (append) : 0); + len = strlen (home) + (append ? strlen (append) : 0) + 1; str = malloc (len); if (str == NULL) { perror ("malloc"); - exit (1); + exit (EXIT_FAILURE); } strcpy (str, home);