Skip to content

Commit 7b293c7

Browse files
committed
patch 8.2.0539: comparing two NULL list fails
Problem: Comparing two NULL list fails. Solution: Change the order of comparing two lists.
1 parent 9c8bb7c commit 7b293c7

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/list.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,15 @@ list_equal(
368368
{
369369
listitem_T *item1, *item2;
370370

371-
if (l1 == NULL || l2 == NULL)
372-
return FALSE;
373371
if (l1 == l2)
374372
return TRUE;
375373
if (list_len(l1) != list_len(l2))
376374
return FALSE;
375+
if (list_len(l1) == 0)
376+
// empty and NULL list are considered equal
377+
return TRUE;
378+
if (l1 == NULL || l2 == NULL)
379+
return FALSE;
377380

378381
range_list_materialize(l1);
379382
range_list_materialize(l2);

src/testdir/test_assert.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ func Test_assert_equal()
3636
call assert_equal(0, assert_equal(4, n))
3737
let l = [1, 2, 3]
3838
call assert_equal(0, assert_equal([1, 2, 3], l))
39+
call assert_equal(test_null_list(), test_null_list())
40+
call assert_equal(test_null_list(), [])
41+
call assert_equal([], test_null_list())
3942

4043
let s = 'foo'
4144
call assert_equal(1, assert_equal('bar', s))

src/version.c

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

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
539,
741743
/**/
742744
538,
743745
/**/

0 commit comments

Comments
 (0)