mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #2491: Fix xfree of static value from vim_getenv() refactor.
Reviewed-by: Eliseo Martínez <eliseomarmol@gmail.com>
This commit is contained in:
commit
920381c01b
@ -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,7 +3904,9 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file,
|
||||
|
||||
xfree(buf);
|
||||
xfree(pat);
|
||||
xfree(path);
|
||||
if (mustfree) {
|
||||
xfree(path);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user