From: John Marriott Date: Mon, 2 Mar 2026 18:44:33 +0000 (+0000) Subject: patch 9.2.0091: missing out-of-memory checks in quickfix.c X-Git-Tag: v9.2.0091^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01554015384e1f8016ee29209e0c370a9e79b80d;p=thirdparty%2Fvim.git patch 9.2.0091: missing out-of-memory checks in quickfix.c Problem: missing out-of-memory checks in quickfix.c Solution: Improve error handline, refactor qf_push_dir() slightly (John Marriott). closes: #19528 Signed-off-by: John Marriott Signed-off-by: Christian Brabandt --- diff --git a/src/quickfix.c b/src/quickfix.c index a7ec10bfe0..40b4174897 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -2757,6 +2757,8 @@ qf_get_fnum(qf_list_T *qfl, char_u *directory, char_u *fname) ptr = concat_fnames(directory, fname, TRUE); else ptr = vim_strsave(fname); + if (ptr == NULL) + return 0; } // Use concatenated directory name and file name bufname = ptr; @@ -2798,11 +2800,12 @@ qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, int is_file_stack) struct dir_stack_T *ds_new; struct dir_stack_T *ds_ptr; - // allocate new stack element and hook it in + // allocate new stack element ds_new = ALLOC_ONE_ID(struct dir_stack_T, aid_qf_dirstack); if (ds_new == NULL) return NULL; + // push the new element onto the stack ds_new->next = *stackptr; *stackptr = ds_new; @@ -2820,11 +2823,24 @@ qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, int is_file_stack) (*stackptr)->dirname = NULL; while (ds_new) { - vim_free((*stackptr)->dirname); - (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf, - TRUE); - if (mch_isdir((*stackptr)->dirname) == TRUE) + char_u *dirname; + + dirname = concat_fnames(ds_new->dirname, dirbuf, TRUE); + if (dirname == NULL) + { + // pop the new element from the stack and free it + ds_ptr = *stackptr; + *stackptr = (*stackptr)->next; + vim_free(ds_ptr); + + return NULL; + } + if (mch_isdir(dirname) == TRUE) + { + vim_free((*stackptr)->dirname); + (*stackptr)->dirname = dirname; break; + } ds_new = ds_new->next; } @@ -2848,13 +2864,13 @@ qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, int is_file_stack) if ((*stackptr)->dirname != NULL) return (*stackptr)->dirname; - else - { - ds_ptr = *stackptr; - *stackptr = (*stackptr)->next; - vim_free(ds_ptr); - return NULL; - } + + // pop the new element from the stack and free it + ds_ptr = *stackptr; + *stackptr = (*stackptr)->next; + vim_free(ds_ptr); + + return NULL; } /* diff --git a/src/version.c b/src/version.c index 5e9309c10e..c7daf91149 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 91, /**/ 90, /**/