aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-14 15:05:12 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-04-14 16:10:09 +0800
commitcc7a50a9ae9384167bd0fc2ee2eb7f1b31842f27 (patch)
treec5a1834b6d8af6db02132b31d4bb994b95ab09d4 /src/nvim/eval.c
parent562840a2a16b4532f6d216c137506a7432c2e0e3 (diff)
downloadrneovim-cc7a50a9ae9384167bd0fc2ee2eb7f1b31842f27.tar.gz
rneovim-cc7a50a9ae9384167bd0fc2ee2eb7f1b31842f27.tar.bz2
rneovim-cc7a50a9ae9384167bd0fc2ee2eb7f1b31842f27.zip
vim-patch:8.2.1161: Vim9: using freed memory
Problem: Vim9: using freed memory. Solution: Put pointer back in evalarg instead of freeing it. https://github.com/vim/vim/commit/8e2730a315b8b06192f5fc822dc218dbb3cff7ae Omit eval_tofree_lambda: Vim9 script only. N/A patches for version.c: vim-patch:8.2.1163: build error Problem: Build error. Solution: Add missing change to globals. https://github.com/vim/vim/commit/6e13530ca03dd9cad245221177dd65f712211448 Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index ec3c2b5e85..9660157592 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -2259,21 +2259,23 @@ static int eval_func(char **const arg, evalarg_T *const evalarg, char *const nam
return ret;
}
-/// After using "evalarg" filled from "eap" free the memory.
+/// After using "evalarg" filled from "eap": free the memory.
void clear_evalarg(evalarg_T *evalarg, exarg_T *eap)
{
- if (evalarg != NULL && evalarg->eval_tofree != NULL) {
- if (eap != NULL) {
- // We may need to keep the original command line, e.g. for
- // ":let" it has the variable names. But we may also need the
- // new one, "nextcmd" points into it. Keep both.
- xfree(eap->cmdline_tofree);
- eap->cmdline_tofree = *eap->cmdlinep;
- *eap->cmdlinep = evalarg->eval_tofree;
- } else {
- xfree(evalarg->eval_tofree);
+ if (evalarg != NULL) {
+ if (evalarg->eval_tofree != NULL) {
+ if (eap != NULL) {
+ // We may need to keep the original command line, e.g. for
+ // ":let" it has the variable names. But we may also need the
+ // new one, "nextcmd" points into it. Keep both.
+ xfree(eap->cmdline_tofree);
+ eap->cmdline_tofree = *eap->cmdlinep;
+ *eap->cmdlinep = evalarg->eval_tofree;
+ } else {
+ xfree(evalarg->eval_tofree);
+ }
+ evalarg->eval_tofree = NULL;
}
- evalarg->eval_tofree = NULL;
}
}