aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/command.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-09-29 16:04:14 +0800
committerGitHub <noreply@github.com>2022-09-29 16:04:14 +0800
commit45707c1eae62667e5c482a09f6d9a62e01db0e21 (patch)
tree63fb5841b35a53b2b991f29a738c002fea28efa7 /src/nvim/api/command.c
parent1cf44d6f5794c7b6bd181dfb2ce51f5ff4381ee8 (diff)
downloadrneovim-45707c1eae62667e5c482a09f6d9a62e01db0e21.tar.gz
rneovim-45707c1eae62667e5c482a09f6d9a62e01db0e21.tar.bz2
rneovim-45707c1eae62667e5c482a09f6d9a62e01db0e21.zip
fix(api): fix nvim_cmd crash with filename expansion (#20397)
Diffstat (limited to 'src/nvim/api/command.c')
-rw-r--r--src/nvim/api/command.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c
index 699c62c15c..ab166c6b38 100644
--- a/src/nvim/api/command.c
+++ b/src/nvim/api/command.c
@@ -830,13 +830,12 @@ static void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdin
// Replace, :make and :grep with 'makeprg' and 'grepprg'.
char *p = replace_makeprg(eap, eap->arg, cmdlinep);
if (p != eap->arg) {
- // If replace_makeprg modified the cmdline string, correct the argument pointers.
+ // If replace_makeprg() modified the cmdline string, correct the eap->arg pointer.
eap->arg = p;
- // We can only know the position of the first argument because the argument list can be used
- // multiple times in makeprg / grepprg.
- if (argc >= 1) {
- eap->args[0] = p;
- }
+ // This cannot be a user command, so eap->args will not be used.
+ XFREE_CLEAR(eap->args);
+ XFREE_CLEAR(eap->arglens);
+ eap->argc = 0;
}
}