Merge #2491: Fix xfree of static value from vim_getenv() refactor.

Reviewed-by: Eliseo Martínez <eliseomarmol@gmail.com>
This commit is contained in:
Eliseo Martínez 2015-04-23 22:00:00 +02:00
commit 920381c01b

View File

@ -3842,6 +3842,7 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file,
flags |= EW_FILE | EW_EXEC; flags |= EW_FILE | EW_EXEC;
bool mustfree = false; // Track memory allocation for *path.
/* For an absolute name we don't use $PATH. */ /* For an absolute name we don't use $PATH. */
if (path_is_absolute_path(pat)) if (path_is_absolute_path(pat))
path = (char_u *)" "; path = (char_u *)" ";
@ -3850,8 +3851,11 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file,
path = (char_u *)"."; path = (char_u *)".";
else { else {
path = (char_u *)vim_getenv("PATH"); path = (char_u *)vim_getenv("PATH");
if (path == NULL) if (path == NULL) {
path = (char_u *)""; path = (char_u *)"";
} else {
mustfree = true;
}
} }
/* /*
@ -3900,7 +3904,9 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file,
xfree(buf); xfree(buf);
xfree(pat); xfree(pat);
xfree(path); if (mustfree) {
xfree(path);
}
} }
/* /*