diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-07-22 21:12:25 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-07-24 01:15:24 -0400 |
commit | f0a702d1169a77334f1481d19fc08f8d8413083a (patch) | |
tree | de535a4a5936b63c5f84d486eaa85c3f7a9aa221 | |
parent | 563957e3cb778305230a2b1f9d5d64a682b60b7a (diff) | |
download | rneovim-f0a702d1169a77334f1481d19fc08f8d8413083a.tar.gz rneovim-f0a702d1169a77334f1481d19fc08f8d8413083a.tar.bz2 rneovim-f0a702d1169a77334f1481d19fc08f8d8413083a.zip |
file_search: free stackp if vim_findfile() failed
ff_free_stack_element() accepts NULL ptr and returns early.
This removes the need to check if stackp is not NULL.
-rw-r--r-- | src/nvim/file_search.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index ebe6dce5b1..6c1a2f6d7b 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -577,7 +577,7 @@ char_u *vim_findfile(void *search_ctx_arg) char_u *file_path; char_u *rest_of_wildcards; char_u *path_end = NULL; - ff_stack_T *stackp; + ff_stack_T *stackp = NULL; size_t len; char_u *p; char_u *suf; @@ -964,6 +964,7 @@ char_u *vim_findfile(void *search_ctx_arg) } fail: + ff_free_stack_element(stackp); xfree(file_path); return NULL; } @@ -1222,6 +1223,10 @@ static ff_stack_T *ff_pop(ff_search_ctx_T *search_ctx) */ static void ff_free_stack_element(ff_stack_T *stack_ptr) { + if (stack_ptr == NULL) { + return; + } + /* free handles possible NULL pointers */ xfree(stack_ptr->ffs_fix_path); xfree(stack_ptr->ffs_wc_path); |