]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1975: blob2str() may call STRNCPY() with a NULL pointer v9.1.1975
authorFoxe Chen <chen.foxe@gmail.com>
Fri, 12 Dec 2025 07:52:07 +0000 (08:52 +0100)
committerChristian Brabandt <cb@256bit.org>
Fri, 12 Dec 2025 07:52:07 +0000 (08:52 +0100)
Problem:  blob2str() may call strcpy with a NULL pointer
Solution: Check for NULL before calling STRNCPY()

closes: #18907

Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/strings.c
src/version.c

index 8bcd38a8fa29c988084d37754e7be779d480c7a4..228cff242cc60d9c446ad09a44f6a8f4a2df99b4 100644 (file)
@@ -1242,6 +1242,7 @@ string_from_blob(blob_T *blob, long *start_idx)
     garray_T   str_ga;
     long       blen;
     int                idx;
+    char_u     *ret_str = NULL;
 
     ga_init2(&str_ga, sizeof(char), 80);
 
@@ -1262,7 +1263,8 @@ string_from_blob(blob_T *blob, long *start_idx)
        ga_append(&str_ga, byte);
     }
 
-    char_u *ret_str = vim_strnsave(str_ga.ga_data, str_ga.ga_len);
+    if (str_ga.ga_data != NULL)
+       ret_str = vim_strnsave(str_ga.ga_data, str_ga.ga_len);
     *start_idx = idx;
 
     ga_clear(&str_ga);
index a461d58c96bf25f2e774c1475ca8304577e3442f..467629519f918c9e0d1a44fb556fc987a68e0683 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1975,
 /**/
     1974,
 /**/