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

View File

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