forked from aniani/vim
patch 7.4.1847
Problem: Getting an item from a NULL dict crashes. Setting a register to a NULL list crashes. (Nikolai Pavlov, issue #768) Comparing a NULL dict with a NULL dict fails. Solution: Properly check for NULL.
This commit is contained in:
12
src/eval.c
12
src/eval.c
@@ -6230,6 +6230,8 @@ dict_equal(
|
|||||||
dictitem_T *item2;
|
dictitem_T *item2;
|
||||||
int todo;
|
int todo;
|
||||||
|
|
||||||
|
if (d1 == NULL && d2 == NULL)
|
||||||
|
return TRUE;
|
||||||
if (d1 == NULL || d2 == NULL)
|
if (d1 == NULL || d2 == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (d1 == d2)
|
if (d1 == d2)
|
||||||
@@ -7763,6 +7765,8 @@ dict_find(dict_T *d, char_u *key, int len)
|
|||||||
char_u *tofree = NULL;
|
char_u *tofree = NULL;
|
||||||
hashitem_T *hi;
|
hashitem_T *hi;
|
||||||
|
|
||||||
|
if (d == NULL)
|
||||||
|
return NULL;
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
akey = key;
|
akey = key;
|
||||||
else if (len >= AKEYLEN)
|
else if (len >= AKEYLEN)
|
||||||
@@ -18603,8 +18607,12 @@ f_setreg(typval_T *argvars, typval_T *rettv)
|
|||||||
char_u buf[NUMBUFLEN];
|
char_u buf[NUMBUFLEN];
|
||||||
char_u **curval;
|
char_u **curval;
|
||||||
char_u **curallocval;
|
char_u **curallocval;
|
||||||
int len = argvars[1].vval.v_list->lv_len;
|
list_T *ll = argvars[1].vval.v_list;
|
||||||
listitem_T *li;
|
listitem_T *li;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
/* If the list is NULL handle like an empty list. */
|
||||||
|
len = ll == NULL ? 0 : ll->lv_len;
|
||||||
|
|
||||||
/* First half: use for pointers to result lines; second half: use for
|
/* First half: use for pointers to result lines; second half: use for
|
||||||
* pointers to allocated copies. */
|
* pointers to allocated copies. */
|
||||||
@@ -18615,7 +18623,7 @@ f_setreg(typval_T *argvars, typval_T *rettv)
|
|||||||
allocval = lstval + len + 2;
|
allocval = lstval + len + 2;
|
||||||
curallocval = allocval;
|
curallocval = allocval;
|
||||||
|
|
||||||
for (li = argvars[1].vval.v_list->lv_first; li != NULL;
|
for (li = ll == NULL ? NULL : ll->lv_first; li != NULL;
|
||||||
li = li->li_next)
|
li = li->li_next)
|
||||||
{
|
{
|
||||||
strval = get_tv_string_buf_chk(&li->li_tv, buf);
|
strval = get_tv_string_buf_chk(&li->li_tv, buf);
|
||||||
|
@@ -90,3 +90,14 @@ func Test_loop_over_null_list()
|
|||||||
call assert_true(0, 'should not get here')
|
call assert_true(0, 'should not get here')
|
||||||
endfor
|
endfor
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_compare_null_dict()
|
||||||
|
call assert_fails('let x = test_null_dict()[10]')
|
||||||
|
call assert_equal({}, {})
|
||||||
|
call assert_equal(test_null_dict(), test_null_dict())
|
||||||
|
call assert_notequal({}, test_null_dict())
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_set_reg_null_list()
|
||||||
|
call setreg('x', test_null_list())
|
||||||
|
endfunc
|
||||||
|
@@ -753,6 +753,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1847,
|
||||||
/**/
|
/**/
|
||||||
1846,
|
1846,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user