Skip to content

Commit 90b3975

Browse files
yegappanchrisbra
authored andcommitted
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 <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 2cb8246 commit 90b3975

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/strings.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,9 +1366,10 @@ f_blob2str(typval_T *argvars, typval_T *rettv)
13661366
}
13671367
}
13681368

1369-
if (list_append_string(rettv->vval.v_list, converted_str, -1) == FAIL)
1370-
break;
1369+
int ret = list_append_string(rettv->vval.v_list, converted_str, -1);
13711370
vim_free(converted_str);
1371+
if (ret == FAIL)
1372+
break;
13721373
}
13731374

13741375
done:

src/testdir/test_functions.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4311,6 +4311,10 @@ func Test_blob2str()
43114311
call assert_equal(["🁰🁳"], blob2str(0zF09F81B0.F09F81B3))
43124312
call assert_equal(['«»'], blob2str(0zABBB, {'encoding': 'latin1'}))
43134313
call assert_equal(['«»'], blob2str(0zC2ABC2BB, {'encoding': 'utf8'}))
4314+
call assert_equal(['«»'], blob2str(0zC2ABC2BB, {'encoding': 'utf-8'}))
4315+
4316+
call assert_equal(['a'], blob2str(0z61, test_null_dict()))
4317+
call assert_equal(['a'], blob2str(0z61, {'encoding': test_null_string()}))
43144318

43154319
#" Invalid encoding
43164320
call assert_fails("call blob2str(0z80)", "E1515: Unable to convert from 'utf-8' encoding")

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
1035,
707709
/**/
708710
1034,
709711
/**/

0 commit comments

Comments
 (0)