]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0091: missing out-of-memory checks in quickfix.c v9.2.0091
authorJohn Marriott <basilisk@internode.on.net>
Mon, 2 Mar 2026 18:44:33 +0000 (18:44 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 2 Mar 2026 18:44:33 +0000 (18:44 +0000)
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 <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/quickfix.c
src/version.c

index a7ec10bfe0f84748b42628a9fffa50e41c51d159..40b4174897539d7b335525feed421ef97c660817 100644 (file)
@@ -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;
 }
 
 /*
index 5e9309c10e26cb1b22880ccfb9ee81d08d6c2fa3..c7daf91149ee470c3e5e025273224fe92f483f94 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    91,
 /**/
     90,
 /**/