Skip to content

Commit a542c68

Browse files
committed
patch 7.4.1223
Problem: Crash when setting v:errors to a number. Solution: Free the typval without assuming its type. (Yasuhiro Matsumoto)
1 parent e2c3810 commit a542c68

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

src/eval.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,8 @@ eval_init(void)
919919
/* add to compat scope dict */
920920
hash_add(&compat_hashtab, p->vv_di.di_key);
921921
}
922+
vimvars[VV_VERSION].vv_nr = VIM_VERSION_100;
923+
922924
set_vim_var_nr(VV_SEARCHFORWARD, 1L);
923925
set_vim_var_nr(VV_HLSEARCH, 1L);
924926
set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc());
@@ -20616,11 +20618,8 @@ set_vim_var_string(
2061620618
char_u *val,
2061720619
int len) /* length of "val" to use or -1 (whole string) */
2061820620
{
20619-
/* Need to do this (at least) once, since we can't initialize a union.
20620-
* Will always be invoked when "v:progname" is set. */
20621-
vimvars[VV_VERSION].vv_nr = VIM_VERSION_100;
20622-
20623-
vim_free(vimvars[idx].vv_str);
20621+
clear_tv(&vimvars[idx].vv_di.di_tv);
20622+
vimvars[idx].vv_type = VAR_STRING;
2062420623
if (val == NULL)
2062520624
vimvars[idx].vv_str = NULL;
2062620625
else if (len == -1)
@@ -20635,7 +20634,8 @@ set_vim_var_string(
2063520634
void
2063620635
set_vim_var_list(int idx, list_T *val)
2063720636
{
20638-
list_unref(vimvars[idx].vv_list);
20637+
clear_tv(&vimvars[idx].vv_di.di_tv);
20638+
vimvars[idx].vv_type = VAR_LIST;
2063920639
vimvars[idx].vv_list = val;
2064020640
if (val != NULL)
2064120641
++val->lv_refcount;
@@ -20650,7 +20650,8 @@ set_vim_var_dict(int idx, dict_T *val)
2065020650
int todo;
2065120651
hashitem_T *hi;
2065220652

20653-
dict_unref(vimvars[idx].vv_dict);
20653+
clear_tv(&vimvars[idx].vv_di.di_tv);
20654+
vimvars[idx].vv_type = VAR_DICT;
2065420655
vimvars[idx].vv_dict = val;
2065520656
if (val != NULL)
2065620657
{

src/testdir/test_assert.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ func Test_assert_exception()
3737
endtry
3838
endfunc
3939

40+
func Test_wrong_error_type()
41+
let save_verrors = v:errors
42+
let v:['errors'] = {'foo': 3}
43+
call assert_equal('yes', 'no')
44+
let verrors = v:errors
45+
let v:errors = save_verrors
46+
call assert_equal(type([]), type(verrors))
47+
endfunc
48+
4049
func Test_user_is_happy()
4150
smile
4251
sleep 300m

src/version.c

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

743743
static int included_patches[] =
744744
{ /* Add new patch number below this line */
745+
/**/
746+
1223,
745747
/**/
746748
1222,
747749
/**/

0 commit comments

Comments
 (0)