aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliseo Martínez <eliseomarmol@gmail.com>2015-04-23 22:00:00 +0200
committerEliseo Martínez <eliseomarmol@gmail.com>2015-04-23 22:00:00 +0200
commit920381c01b72724d4088b1a807eeda8e468194da (patch)
tree34a8fb8e2328186fa780583f4ccbcc61b04ac965
parent1383c5f6cb053ff278bd86e5acc3224b16af5d87 (diff)
parentb68ce1460db13a8a443ec3c3da5c30f8f592e157 (diff)
downloadrneovim-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>
-rw-r--r--src/nvim/ex_getln.c10
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);
+ }
}
/*