patch 9.1.1218: missing out-of-memory check in filepath.c

Commit: 
https://github.com/vim/vim/commit/c00729824d6d335994252a462cc78be52b76f85b
Author: John Marriott <basil...@internode.on.net>
Date:   Mon Mar 17 21:14:17 2025 +0100

    patch 9.1.1218: missing out-of-memory check in filepath.c
    
    Problem:  missing out-of-memory check in filepath.c
    Solution: Add check for NULL (John Marriott)
    
    closes: #16906
    
    Signed-off-by: John Marriott <basil...@internode.on.net>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/filepath.c b/src/filepath.c
index 080a58e8a..15f770f42 100644
--- a/src/filepath.c
+++ b/src/filepath.c
@@ -105,7 +105,9 @@ shortpath_for_invalid_fname(
     char_u     **bufp,
     size_t     *fnamelen)
 {
-    char_u     *short_fname, *save_fname, *pbuf_unused;
+    char_u     *save_fname;
+    char_u     *pbuf_unused = NULL;
+    char_u     *short_fname = NULL;
     char_u     *endp, *save_endp;
     char_u     ch;
     size_t     old_len;
@@ -116,8 +118,11 @@ shortpath_for_invalid_fname(
     // Make a copy
     old_len = *fnamelen;
     save_fname = vim_strnsave(*fname, old_len);
-    pbuf_unused = NULL;
-    short_fname = NULL;
+    if (save_fname == NULL)
+    {
+       retval = FAIL;
+       goto theend;
+    }
 
     endp = save_fname + old_len - 1; // Find the end of the copy
     save_endp = endp;
@@ -233,6 +238,8 @@ shortpath_for_partial(
        pbuf = tfname = expand_env_save(*fnamep);
     else
        pbuf = tfname = FullName_save(*fnamep, FALSE);
+    if (tfname == NULL)
+       return FAIL;
 
     len = tflen = STRLEN(tfname);
 
diff --git a/src/version.c b/src/version.c
index e8d5523b6..2f28686f9 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1218,
 /**/
     1217,
 /**/

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1tuH63-00GgBK-F0%40256bit.org.

Raspunde prin e-mail lui