From: zeertzjq Date: Thu, 17 Jul 2025 18:12:17 +0000 (+0200) Subject: patch 9.1.1558: str2blob() treats NULL string and empty string differently X-Git-Tag: v9.1.1558^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e154d8135abaea76ee1b81240daf46ae091b86b;p=thirdparty%2Fvim.git patch 9.1.1558: str2blob() treats NULL string and empty string differently Problem: str2blob() treats NULL string and empty string differently Solution: Treats a NULL string the same as an empty string (zeertzjq). closes: #17778 Signed-off-by: zeertzjq Signed-off-by: Yegappan Lakshmanan Signed-off-by: Christian Brabandt --- diff --git a/src/strings.c b/src/strings.c index c356c36665..87868b90c4 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1407,7 +1407,7 @@ f_str2blob(typval_T *argvars, typval_T *rettv) char_u *str = li->li_tv.vval.v_string; if (str == NULL) - continue; + str = (char_u *)""; if (to_encoding != NULL) { diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index 4fac4726fa..fccd5af491 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -4411,13 +4411,17 @@ func Test_str2blob() call assert_equal(0z, str2blob([""])) call assert_equal(0z, str2blob([])) call assert_equal(0z, str2blob(test_null_list())) - call assert_equal(0z, str2blob([test_null_string(), test_null_string()])) + call assert_equal(0z, str2blob([test_null_string()])) + call assert_equal(0z0A, str2blob([test_null_string(), test_null_string()])) call assert_fails("call str2blob('')", 'E1211: List required for argument 1') call assert_equal(0z61, str2blob(["a"])) call assert_equal(0z6162, str2blob(["ab"])) call assert_equal(0z610062, str2blob(["a\nb"])) call assert_equal(0z61620A6364, str2blob(["ab", "cd"])) call assert_equal(0z0A, str2blob(["", ""])) + call assert_equal(0z610A62, str2blob(["a", "b"])) + call assert_equal(0z610A0A62, str2blob(["a", "", "b"])) + call assert_equal(0z610A0A62, str2blob(["a", test_null_string(), "b"])) call assert_equal(0zC2ABC2BB, str2blob(["«»"])) call assert_equal(0zC59DC59F, str2blob(["ŝş"])) diff --git a/src/version.c b/src/version.c index d2710bc1a4..638dfc6bbe 100644 --- a/src/version.c +++ b/src/version.c @@ -719,6 +719,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1558, /**/ 1557, /**/