aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-21 07:20:26 +0800
committerGitHub <noreply@github.com>2023-08-21 07:20:26 +0800
commitac99e63d73df84cc20766ad86655724f3a0345b9 (patch)
tree215ffed160148962d9e0ae03f4d376e12fa7e669 /src
parentd21e6285e93302b6d387ad6d362b683db09c5239 (diff)
downloadrneovim-ac99e63d73df84cc20766ad86655724f3a0345b9.tar.gz
rneovim-ac99e63d73df84cc20766ad86655724f3a0345b9.tar.bz2
rneovim-ac99e63d73df84cc20766ad86655724f3a0345b9.zip
vim-patch:9.0.1763: crash when passing invalid buffer to undotree() (#24807)
Problem: crash when passing invalid buffer to undotree() Solution: Use get_buf_arg() instead of tv_get_buf_from_arg(). closes: vim/vim#12862 closes: vim/vim#12830 https://github.com/vim/vim/commit/ab9f2ecfd4ecaf74eeed0e5ec41355589af3ec8f
Diffstat (limited to 'src')
-rw-r--r--src/nvim/undo.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index 695cf81f73..e27304f04c 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -3171,11 +3171,14 @@ void f_undofile(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
/// "undotree(expr)" function
void f_undotree(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
- typval_T *const tv = &argvars[0];
- buf_T *const buf = tv->v_type == VAR_UNKNOWN ? curbuf : tv_get_buf_from_arg(tv);
-
tv_dict_alloc_ret(rettv);
+ typval_T *const tv = &argvars[0];
+ buf_T *const buf = tv->v_type == VAR_UNKNOWN ? curbuf : get_buf_arg(tv);
+ if (buf == NULL) {
+ return;
+ }
+
dict_T *dict = rettv->vval.v_dict;
tv_dict_add_nr(dict, S_LEN("synced"), (varnumber_T)buf->b_u_synced);