aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_cmds2.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index a602719f6d..b62bb8b42a 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -227,9 +227,12 @@ void dialog_changed(buf_T *buf, bool checkall)
// restore to empty when write failed
if (empty_bufname) {
- XFREE_CLEAR(buf->b_fname);
+ // prevent double free
+ if (buf->b_sfname != buf->b_ffname) {
+ XFREE_CLEAR(buf->b_sfname);
+ }
+ buf->b_fname = NULL;
XFREE_CLEAR(buf->b_ffname);
- XFREE_CLEAR(buf->b_sfname);
unchanged(buf, true, false);
}
} else if (ret == VIM_NO) {