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 <zeertzjq@outlook.com>
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2025-07-17 20:12:17 +02:00
committed by Christian Brabandt
parent 0d9160e11c
commit 2e154d8135
3 changed files with 8 additions and 2 deletions

View File

@ -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)
{

View File

@ -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(["ŝş"]))

View File

@ -719,6 +719,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1558,
/**/
1557,
/**/