patch 9.2.0091: missing out-of-memory checks in quickfix.c

Commit: 
https://github.com/vim/vim/commit/01554015384e1f8016ee29209e0c370a9e79b80d
Author: John Marriott <[email protected]>
Date:   Mon Mar 2 18:44:33 2026 +0000

    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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/quickfix.c b/src/quickfix.c
index a7ec10bfe..40b417489 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 5e9309c10..c7daf9114 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,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vx8Uu-003XuO-1J%40256bit.org.

Raspunde prin e-mail lui