diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-08-03 08:45:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-03 08:45:55 +0800 |
commit | 4f3801c9257e364d777d4324489afefa6b5d3fff (patch) | |
tree | c9e3ed0907c41ba2e7185abe909fe87d945efe76 | |
parent | 383f6934720a203d093c762cbd5362092110f35f (diff) | |
parent | 4c886d0e732b1e5626b7c410b142ccd0b0868cb7 (diff) | |
download | rneovim-4f3801c9257e364d777d4324489afefa6b5d3fff.tar.gz rneovim-4f3801c9257e364d777d4324489afefa6b5d3fff.tar.bz2 rneovim-4f3801c9257e364d777d4324489afefa6b5d3fff.zip |
Merge pull request #29967 from zeertzjq/vim-9.1.0648
vim-patch:9.1.{0648,0653}
-rw-r--r-- | src/nvim/ex_cmds2.c | 2 | ||||
-rw-r--r-- | test/functional/legacy/crash_spec.lua | 12 | ||||
-rw-r--r-- | test/old/testdir/crash/dialog_changed_uaf | bin | 0 -> 552 bytes | |||
-rw-r--r-- | test/old/testdir/test_crash.vim | 6 |
4 files changed, 19 insertions, 1 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index a602719f6d..210539d6a4 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -227,7 +227,7 @@ void dialog_changed(buf_T *buf, bool checkall) // restore to empty when write failed if (empty_bufname) { - XFREE_CLEAR(buf->b_fname); + buf->b_fname = NULL; XFREE_CLEAR(buf->b_ffname); XFREE_CLEAR(buf->b_sfname); unchanged(buf, true, false); diff --git a/test/functional/legacy/crash_spec.lua b/test/functional/legacy/crash_spec.lua index e72c3a512a..b63b3146f4 100644 --- a/test/functional/legacy/crash_spec.lua +++ b/test/functional/legacy/crash_spec.lua @@ -8,6 +8,7 @@ local eq = t.eq local eval = n.eval local exec = n.exec local feed = n.feed +local pcall_err = t.pcall_err before_each(clear) @@ -51,3 +52,14 @@ it('no crash when closing window with tag in loclist', function() eq(0, eval('bufexists(g:qf_bufnr)')) assert_alive() end) + +it('no crash when writing "Untitled" file fails', function() + t.mkdir('Untitled') + finally(function() + vim.uv.fs_rmdir('Untitled') + end) + feed('ifoobar') + command('set bufhidden=unload') + eq('Vim(enew):E502: "Untitled" is a directory', pcall_err(command, 'confirm enew')) + assert_alive() +end) diff --git a/test/old/testdir/crash/dialog_changed_uaf b/test/old/testdir/crash/dialog_changed_uaf Binary files differnew file mode 100644 index 0000000000..e37d18d6da --- /dev/null +++ b/test/old/testdir/crash/dialog_changed_uaf diff --git a/test/old/testdir/test_crash.vim b/test/old/testdir/test_crash.vim index 29061aa423..9aef245026 100644 --- a/test/old/testdir/test_crash.vim +++ b/test/old/testdir/test_crash.vim @@ -196,6 +196,12 @@ func Test_crash1_3() call term_sendkeys(buf, args) call TermWait(buf, 50) + let file = 'crash/dialog_changed_uaf' + let cmn_args = "%s -u NONE -i NONE -n -e -s -S %s -c ':qa!'\<cr>" + let args = printf(cmn_args, vim, file) + call term_sendkeys(buf, args) + call TermWait(buf, 150) + " clean up exe buf .. "bw!" bw! |