summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-10-13 19:08:24 +0200
committerBram Moolenaar <Bram@vim.org>2020-10-13 19:08:24 +0200
commit21cbe175eece17fad21d7403b00422445b587138 (patch)
treef266f1ec7f373d0f8c975075eb50cb0805ff9960 /src
parent2b9b17ea5daaaa693d0891e9a999d711f0e0f743 (diff)
patch 8.2.1842: crash when USE_FNAME_CASE is defined and using :browsev8.2.1842
Problem: Crash when USE_FNAME_CASE is defined and using :browse. Solution: Don't use read-only memory for ".". (Yegappan Lakshmanan, closes #7123)
Diffstat (limited to 'src')
-rw-r--r--src/ex_cmds.c3
-rw-r--r--src/ex_docmd.c3
-rw-r--r--src/testdir/test_edit.vim18
-rw-r--r--src/version.c2
4 files changed, 24 insertions, 2 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index a55fae709a..6371eceba1 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -2465,6 +2465,7 @@ do_ecmd(
bufref_T old_curbuf;
char_u *free_fname = NULL;
#ifdef FEAT_BROWSE
+ char_u dot_path[] = ".";
char_u *browse_file = NULL;
#endif
int retval = FAIL;
@@ -2511,7 +2512,7 @@ do_ecmd(
// No browsing supported but we do have the file explorer:
// Edit the directory.
if (ffname == NULL || !mch_isdir(ffname))
- ffname = (char_u *)".";
+ ffname = dot_path;
}
else
{
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 112cb9eab9..1fc67eaec7 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -6084,6 +6084,7 @@ ex_splitview(exarg_T *eap)
char_u *fname = NULL;
#endif
#ifdef FEAT_BROWSE
+ char_u dot_path[] = ".";
int browse_flag = cmdmod.browse;
#endif
int use_tab = eap->cmdidx == CMD_tabedit
@@ -6136,7 +6137,7 @@ ex_splitview(exarg_T *eap)
// No browsing supported but we do have the file explorer:
// Edit the directory.
if (*eap->arg == NUL || !mch_isdir(eap->arg))
- eap->arg = (char_u *)".";
+ eap->arg = dot_path;
}
else
{
diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim
index 6607345575..ac893f39bc 100644
--- a/src/testdir/test_edit.vim
+++ b/src/testdir/test_edit.vim
@@ -1805,4 +1805,22 @@ func Test_edit_lastline_scroll()
close!
endfunc
+func Test_edit_browse()
+ " in the GUI this opens a file picker, we only test the terminal behavior
+ CheckNotGui
+
+ " ":browse xxx" checks for the FileExplorer augroup and assumes editing "."
+ " works then.
+ augroup FileExplorer
+ au!
+ augroup END
+
+ " When the USE_FNAME_CASE is defined this used to cause a crash.
+ browse enew
+ bwipe!
+
+ browse split
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 6b336314e4..e32611178f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1842,
+/**/
1841,
/**/
1840,