From 3d06113c8c9628a478b0cf6c85248ff6ec5fac3a Mon Sep 17 00:00:00 2001 From: Foxe Chen Date: Fri, 12 Dec 2025 08:52:07 +0100 Subject: [PATCH] patch 9.1.1975: blob2str() may call STRNCPY() with a NULL pointer Problem: blob2str() may call strcpy with a NULL pointer Solution: Check for NULL before calling STRNCPY() closes: #18907 Signed-off-by: Foxe Chen Signed-off-by: Christian Brabandt --- src/strings.c | 4 +++- src/version.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/strings.c b/src/strings.c index 8bcd38a8fa..228cff242c 100644 --- a/src/strings.c +++ b/src/strings.c @@ -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); diff --git a/src/version.c b/src/version.c index a461d58c96..467629519f 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 */ +/**/ + 1975, /**/ 1974, /**/