mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
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.
This commit is contained in:
@@ -577,7 +577,7 @@ char_u *vim_findfile(void *search_ctx_arg)
|
|||||||
char_u *file_path;
|
char_u *file_path;
|
||||||
char_u *rest_of_wildcards;
|
char_u *rest_of_wildcards;
|
||||||
char_u *path_end = NULL;
|
char_u *path_end = NULL;
|
||||||
ff_stack_T *stackp;
|
ff_stack_T *stackp = NULL;
|
||||||
size_t len;
|
size_t len;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
char_u *suf;
|
char_u *suf;
|
||||||
@@ -964,6 +964,7 @@ char_u *vim_findfile(void *search_ctx_arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
ff_free_stack_element(stackp);
|
||||||
xfree(file_path);
|
xfree(file_path);
|
||||||
return NULL;
|
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)
|
static void ff_free_stack_element(ff_stack_T *stack_ptr)
|
||||||
{
|
{
|
||||||
|
if (stack_ptr == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* free handles possible NULL pointers */
|
/* free handles possible NULL pointers */
|
||||||
xfree(stack_ptr->ffs_fix_path);
|
xfree(stack_ptr->ffs_fix_path);
|
||||||
xfree(stack_ptr->ffs_wc_path);
|
xfree(stack_ptr->ffs_wc_path);
|
||||||
|
Reference in New Issue
Block a user