diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-04-28 16:54:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-28 16:54:00 +0200 |
commit | c76c798bf6377783634eab706339e827fa4fd45f (patch) | |
tree | 67a2cd5c5fd2d1c19910f25d24934d8a62c473de | |
parent | 33b20ce7de24b803a85435fdb53801ee9c247385 (diff) | |
download | rneovim-c76c798bf6377783634eab706339e827fa4fd45f.tar.gz rneovim-c76c798bf6377783634eab706339e827fa4fd45f.tar.bz2 rneovim-c76c798bf6377783634eab706339e827fa4fd45f.zip |
vim-patch:8.1.0843: memory leak when running "make test_cd" #9944
closes #9921
reverts f0a702d1169a
Problem: Memory leak when running "make test_cd".
Solution: Free the stack element when failing. (Dominique Pelle,
closes vim/vim#3877)
https://github.com/vim/vim/commit/e0de2164f62a1736cdc64dbf804b77db8af90c10
-rw-r--r-- | src/nvim/file_search.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index e358f0218e..05611fb8ba 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -687,20 +687,24 @@ char_u *vim_findfile(void *search_ctx_arg) if (!vim_isAbsName(stackp->ffs_fix_path) && search_ctx->ffsc_start_dir) { if (STRLEN(search_ctx->ffsc_start_dir) + 1 >= MAXPATHL) { + ff_free_stack_element(stackp); goto fail; } STRCPY(file_path, search_ctx->ffsc_start_dir); if (!add_pathsep((char *)file_path)) { + ff_free_stack_element(stackp); goto fail; } } // append the fix part of the search path if (STRLEN(file_path) + STRLEN(stackp->ffs_fix_path) + 1 >= MAXPATHL) { + ff_free_stack_element(stackp); goto fail; } STRCAT(file_path, stackp->ffs_fix_path); if (!add_pathsep((char *)file_path)) { + ff_free_stack_element(stackp); goto fail; } @@ -715,6 +719,7 @@ char_u *vim_findfile(void *search_ctx_arg) if (*p > 0) { (*p)--; if (len + 1 >= MAXPATHL) { + ff_free_stack_element(stackp); goto fail; } file_path[len++] = '*'; @@ -743,6 +748,7 @@ char_u *vim_findfile(void *search_ctx_arg) while (*rest_of_wildcards && !vim_ispathsep(*rest_of_wildcards)) { if (len + 1 >= MAXPATHL) { + ff_free_stack_element(stackp); goto fail; } file_path[len++] = *rest_of_wildcards++; @@ -792,10 +798,12 @@ char_u *vim_findfile(void *search_ctx_arg) // prepare the filename to be checked for existence below if (STRLEN(stackp->ffs_filearray[i]) + 1 + STRLEN(search_ctx->ffsc_file_to_search) >= MAXPATHL) { + ff_free_stack_element(stackp); goto fail; } STRCPY(file_path, stackp->ffs_filearray[i]); if (!add_pathsep((char *)file_path)) { + ff_free_stack_element(stackp); goto fail; } STRCAT(file_path, search_ctx->ffsc_file_to_search); @@ -964,7 +972,6 @@ char_u *vim_findfile(void *search_ctx_arg) } fail: - ff_free_stack_element(stackp); xfree(file_path); return NULL; } |