From 271879dd490b8f9c20c5541e60ca2a2924b631d9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 21 Mar 2024 07:34:43 +0800 Subject: vim-patch:9.1.0192: drop: don't rewind when editing the same file Problem: :drop tries to :rewind the argumentlist, which results in E37 (after v9.1.0046) Solution: instead of calling ex_rewind(), call open_buffer() only when re-using the initial empty buffer fixes: vim/vim#14219 closes: vim/vim#14220 https://github.com/vim/vim/commit/978178823b7c62a0249411f3d1f584f8a3144c5d Co-authored-by: Christian Brabandt --- src/nvim/ex_cmds2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index a34eb0232b..fc50664ce0 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -870,7 +870,9 @@ void ex_drop(exarg_T *eap) buf_check_timestamp(curbuf); curbuf->b_p_ar = save_ar; } - ex_rewind(eap); + if (buf->b_ml.ml_flags & ML_EMPTY) { + open_buffer(false, eap, 0); + } return; } } -- cgit From dabc44d15c8ef203b16e00dfa93c5e2639680bc4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 22 Mar 2024 05:54:12 +0800 Subject: vim-patch:9.1.0195: memleak with ex_drop, NULL dereference Problem: memleak with ex_drop(), NULL dereference (zeertzjq) Solution: revert back to ex_rewind(), use curbuf instead of buf fixes: vim/vim#14246 closes: vim/vim#14251 https://github.com/vim/vim/commit/85a769d466d2009db6a318fd120d9691344664ba Co-authored-by: Christian Brabandt --- src/nvim/ex_cmds2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index fc50664ce0..d754150089 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -866,12 +866,12 @@ void ex_drop(exarg_T *eap) const int save_ar = curbuf->b_p_ar; // reload the file if it is newer - curbuf->b_p_ar = 1; + curbuf->b_p_ar = true; buf_check_timestamp(curbuf); curbuf->b_p_ar = save_ar; } - if (buf->b_ml.ml_flags & ML_EMPTY) { - open_buffer(false, eap, 0); + if (curbuf->b_ml.ml_flags & ML_EMPTY) { + ex_rewind(eap); } return; } -- cgit