patch 9.1.1528: completion: crash with getcompletion()

Problem:  completion: crash with getcompletion()
          (zeertzjq)
Solution: Don't set may_expand_pattern in f_getcompletion(),
          unset may_expand_pattern() once it is not longer needed
          (Girish Palya).

fixes: #17680
closes: #17686

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index 75efe1c..bdfa679 100644
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -233,7 +233,6 @@
 
     if (xp->xp_numfiles == -1)
     {
-	may_expand_pattern = options & WILD_MAY_EXPAND_PATTERN;
 	pre_incsearch_pos = xp->xp_pre_incsearch_pos;
 #ifdef FEAT_EVAL
 	if (ccline->input_fn && ccline->xp_context == EXPAND_COMMANDS)
@@ -244,7 +243,9 @@
 	else
 #endif
 	{
+	    may_expand_pattern = options & WILD_MAY_EXPAND_PATTERN;
 	    set_expand_context(xp);
+	    may_expand_pattern = FALSE;
 	}
 	cmd_showtail = expand_showtail(xp);
     }