patch 8.2.2474: using freed memory when window is closed by autocommand

Problem:    Using freed memory when window is closed by autocommand.
            (houyunsong)
Solution:   Check the window pointer is still valid.
diff --git a/src/quickfix.c b/src/quickfix.c
index 742a1ee..910c806 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -2603,6 +2603,8 @@
 
     if (wp != NULL)
     {
+	if (!win_valid(wp))
+	    return FALSE;
 	qi = GET_LOC_LIST(wp);	    // Location list
 	if (qi == NULL)
 	    return FALSE;
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 15d237e..e07731d 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
Binary files differ
diff --git a/src/version.c b/src/version.c
index 254aafd..12a5de8 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2474,
+/**/
     2473,
 /**/
     2472,