patch 9.1.1035: Vim9: memory leak with blob2str() Commit: https://github.com/vim/vim/commit/90b397586decc3751f92fd2f84271a6b431b56bc Author: Yegappan Lakshmanan <yegap...@yahoo.com> Date: Sun Jan 19 09:37:07 2025 +0100
patch 9.1.1035: Vim9: memory leak with blob2str() Problem: Vim9: memory leak with blob2str() Solution: free converted_str (Yegappan Lakshmanan) closes: #16481 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 53e0171aa..120d39355 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1366,9 +1366,10 @@ f_blob2str(typval_T *argvars, typval_T *rettv) } } - if (list_append_string(rettv->vval.v_list, converted_str, -1) == FAIL) - break; + int ret = list_append_string(rettv->vval.v_list, converted_str, -1); vim_free(converted_str); + if (ret == FAIL) + break; } done: diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index bf3e88916..e31e2ed73 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -4311,6 +4311,10 @@ func Test_blob2str() call assert_equal(["🁰🁳"], blob2str(0zF09F81B0.F09F81B3)) call assert_equal(['«»'], blob2str(0zABBB, {'encoding': 'latin1'})) call assert_equal(['«»'], blob2str(0zC2ABC2BB, {'encoding': 'utf8'})) + call assert_equal(['«»'], blob2str(0zC2ABC2BB, {'encoding': 'utf-8'})) + + call assert_equal(['a'], blob2str(0z61, test_null_dict())) + call assert_equal(['a'], blob2str(0z61, {'encoding': test_null_string()})) #" Invalid encoding call assert_fails("call blob2str(0z80)", "E1515: Unable to convert from 'utf-8' encoding") diff --git a/src/version.c b/src/version.c index ba4115977..260f9b53d 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1035, /**/ 1034, /**/ -- -- 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/E1tZQvZ-004YEv-Rf%40256bit.org.