patch 8.0.0571: negative line number when using :z^ in an empty buffer

Problem:    The cursor line number becomes negative when using :z^ in an empty
            buffer. (neovim #6557)
Solution:   Correct the line number.  Also reset the column.
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 4b0bdef..309474c 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -4664,6 +4664,8 @@
 
     if (curs > curbuf->b_ml.ml_line_count)
 	curs = curbuf->b_ml.ml_line_count;
+    else if (curs < 1)
+	curs = 1;
 
     for (i = start; i <= end; i++)
     {
@@ -4686,7 +4688,11 @@
 	}
     }
 
-    curwin->w_cursor.lnum = curs;
+    if (curwin->w_cursor.lnum != curs)
+    {
+	curwin->w_cursor.lnum = curs;
+	curwin->w_cursor.col = 0;
+    }
     ex_no_reprint = TRUE;
 }
 
diff --git a/src/testdir/test_ex_z.vim b/src/testdir/test_ex_z.vim
index 608a36c..6e03b0b 100644
--- a/src/testdir/test_ex_z.vim
+++ b/src/testdir/test_ex_z.vim
@@ -68,7 +68,7 @@
   bw!
 endfunc
 
-func Test_z_bug()
+func Test_z_overflow()
   " This used to access invalid memory as a result of an integer overflow
   " and freeze vim.
   normal ox
@@ -76,3 +76,10 @@
   z777777776666666
   ')
 endfunc
+
+func Test_z_negative_lnum()
+  new
+  z^
+  call assert_equal(1, line('.'))
+  bwipe!
+endfunc
diff --git a/src/version.c b/src/version.c
index c169765..81b98c1 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    571,
+/**/
     570,
 /**/
     569,