patch 9.1.1558: str2blob() treats NULL string and empty string differently

Commit: 
https://github.com/vim/vim/commit/2e154d8135abaea76ee1b81240daf46ae091b86b
Author: zeertzjq <zeert...@outlook.com>
Date:   Thu Jul 17 20:12:17 2025 +0200

    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 <zeert...@outlook.com>
    Signed-off-by: Yegappan Lakshmanan <yegap...@yahoo.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/strings.c b/src/strings.c
index c356c3666..87868b90c 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 4fac4726f..fccd5af49 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
b"]))
     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 d2710bc1a..638dfc6bb 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,
 /**/

-- 
-- 
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/E1ucT8N-00Bbfb-0o%40256bit.org.

Raspunde prin e-mail lui