diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-09-11 11:49:22 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-09-11 11:49:22 +0100 |
commit | f5fec05c7fd0df4c934a838e82882e601dc920cb (patch) | |
tree | 74784b4dea1eba5a74dc5b94e77e61e27ecea097 /src/vim9execute.c | |
parent | 88b79cb7d47e2e1fee1baf4016c50b861e6b21c4 (diff) | |
download | vim-git-f5fec05c7fd0df4c934a838e82882e601dc920cb.tar.gz |
patch 9.0.0440: crash when using mkdir() with "R" flag in compiled functionv9.0.0440
Problem: Crash when using mkdir() with "R" flag in compiled function.
Solution: Reserve a variable for deferred function calls. Handle more than
one argument.
Diffstat (limited to 'src/vim9execute.c')
-rw-r--r-- | src/vim9execute.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/vim9execute.c b/src/vim9execute.c index d4d1ad699..cbf9af7ad 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -932,11 +932,17 @@ defer_command(int var_idx, int argcount, ectx_T *ectx) return FAIL; func_tv = STACK_TV_BOT(-argcount - 1); - // TODO: check type is a funcref + if (func_tv->v_type != VAR_FUNC && func_tv->v_type != VAR_PARTIAL) + { + semsg(_(e_expected_str_but_got_str), + "function or partial", + vartype_name(func_tv->v_type)); + return FAIL; + } list_set_item(l, 0, func_tv); - for (i = 1; i <= argcount; ++i) - list_set_item(l, i, STACK_TV_BOT(-argcount + i - 1)); + for (i = 0; i < argcount; ++i) + list_set_item(l, i + 1, STACK_TV_BOT(-argcount + i)); ectx->ec_stack.ga_len -= argcount + 1; return OK; } @@ -962,7 +968,7 @@ add_defer_function(char_u *name, int argcount, typval_T *argvars) return FAIL; } - l = add_defer_item(dfunc->df_defer_var_idx - 1, 1, current_ectx); + l = add_defer_item(dfunc->df_defer_var_idx - 1, argcount, current_ectx); if (l == NULL) { vim_free(name); |