patch 8.2.4453: :helpgrep may free an option that was not allocated

Problem:    :helpgrep may free an option that was not allocated. (Yegappan
            Lakshmanan)
Solution:   Check if the value was allocated.
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 7d2373b..ccfa340 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -745,6 +745,33 @@
   helpclose
 enddef
 
+func Test_helpgrep_restore_cpo_aucmd()
+  let save_cpo = &cpo
+  augroup QF_Test
+    au!
+    autocmd BufNew * set cpo=acd
+  augroup END
+
+  helpgrep quickfix
+  call assert_equal('acd', &cpo)
+  %bw!
+
+  set cpo&vim
+  augroup QF_Test
+    au!
+    autocmd BufReadPost * set cpo=
+  augroup END
+
+  helpgrep buffer
+  call assert_equal('', &cpo)
+
+  augroup QF_Test
+    au!
+  augroup END
+  %bw!
+  let &cpo = save_cpo
+endfunc
+
 def Test_vim9_cexpr()
   var text = 'somefile:95:error'
   cexpr text