patch 8.2.0539: comparing two NULL list fails

Problem:    Comparing two NULL list fails.
Solution:   Change the order of comparing two lists.
diff --git a/src/list.c b/src/list.c
index 9fe5384..451e585 100644
--- a/src/list.c
+++ b/src/list.c
@@ -368,12 +368,15 @@
 {
     listitem_T	*item1, *item2;
 
-    if (l1 == NULL || l2 == NULL)
-	return FALSE;
     if (l1 == l2)
 	return TRUE;
     if (list_len(l1) != list_len(l2))
 	return FALSE;
+    if (list_len(l1) == 0)
+	// empty and NULL list are considered equal
+	return TRUE;
+    if (l1 == NULL || l2 == NULL)
+	return FALSE;
 
     range_list_materialize(l1);
     range_list_materialize(l2);
diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim
index 1b1f9e5..762f12f 100644
--- a/src/testdir/test_assert.vim
+++ b/src/testdir/test_assert.vim
@@ -36,6 +36,9 @@
   call assert_equal(0, assert_equal(4, n))
   let l = [1, 2, 3]
   call assert_equal(0, assert_equal([1, 2, 3], l))
+  call assert_equal(test_null_list(), test_null_list())
+  call assert_equal(test_null_list(), [])
+  call assert_equal([], test_null_list())
 
   let s = 'foo'
   call assert_equal(1, assert_equal('bar', s))
diff --git a/src/version.c b/src/version.c
index 0c147cc..2bba57d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    539,
+/**/
     538,
 /**/
     537,