diff options
author | Eliseo Martínez <eliseomarmol@gmail.com> | 2015-04-23 22:00:00 +0200 |
---|---|---|
committer | Eliseo Martínez <eliseomarmol@gmail.com> | 2015-04-23 22:00:00 +0200 |
commit | 920381c01b72724d4088b1a807eeda8e468194da (patch) | |
tree | 34a8fb8e2328186fa780583f4ccbcc61b04ac965 /src | |
parent | 1383c5f6cb053ff278bd86e5acc3224b16af5d87 (diff) | |
parent | b68ce1460db13a8a443ec3c3da5c30f8f592e157 (diff) | |
download | rneovim-920381c01b72724d4088b1a807eeda8e468194da.tar.gz rneovim-920381c01b72724d4088b1a807eeda8e468194da.tar.bz2 rneovim-920381c01b72724d4088b1a807eeda8e468194da.zip |
Merge #2491: Fix xfree of static value from vim_getenv() refactor.
Reviewed-by: Eliseo Martínez <eliseomarmol@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_getln.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 9a5da761a5..6c6c72fc36 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -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); + } } /* |