Skip to content

Commit 21cbe17

Browse files
committed
patch 8.2.1842: crash when USE_FNAME_CASE is defined and using :browse
Problem: Crash when USE_FNAME_CASE is defined and using :browse. Solution: Don't use read-only memory for ".". (Yegappan Lakshmanan, closes #7123)
1 parent 2b9b17e commit 21cbe17

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

src/ex_cmds.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2465,6 +2465,7 @@ do_ecmd(
24652465
bufref_T old_curbuf;
24662466
char_u *free_fname = NULL;
24672467
#ifdef FEAT_BROWSE
2468+
char_u dot_path[] = ".";
24682469
char_u *browse_file = NULL;
24692470
#endif
24702471
int retval = FAIL;
@@ -2511,7 +2512,7 @@ do_ecmd(
25112512
// No browsing supported but we do have the file explorer:
25122513
// Edit the directory.
25132514
if (ffname == NULL || !mch_isdir(ffname))
2514-
ffname = (char_u *)".";
2515+
ffname = dot_path;
25152516
}
25162517
else
25172518
{

src/ex_docmd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6084,6 +6084,7 @@ ex_splitview(exarg_T *eap)
60846084
char_u *fname = NULL;
60856085
#endif
60866086
#ifdef FEAT_BROWSE
6087+
char_u dot_path[] = ".";
60876088
int browse_flag = cmdmod.browse;
60886089
#endif
60896090
int use_tab = eap->cmdidx == CMD_tabedit
@@ -6136,7 +6137,7 @@ ex_splitview(exarg_T *eap)
61366137
// No browsing supported but we do have the file explorer:
61376138
// Edit the directory.
61386139
if (*eap->arg == NUL || !mch_isdir(eap->arg))
6139-
eap->arg = (char_u *)".";
6140+
eap->arg = dot_path;
61406141
}
61416142
else
61426143
{

src/testdir/test_edit.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,4 +1805,22 @@ func Test_edit_lastline_scroll()
18051805
close!
18061806
endfunc
18071807

1808+
func Test_edit_browse()
1809+
" in the GUI this opens a file picker, we only test the terminal behavior
1810+
CheckNotGui
1811+
1812+
" ":browse xxx" checks for the FileExplorer augroup and assumes editing "."
1813+
" works then.
1814+
augroup FileExplorer
1815+
au!
1816+
augroup END
1817+
1818+
" When the USE_FNAME_CASE is defined this used to cause a crash.
1819+
browse enew
1820+
bwipe!
1821+
1822+
browse split
1823+
bwipe!
1824+
endfunc
1825+
18081826
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1842,
753755
/**/
754756
1841,
755757
/**/

0 commit comments

Comments
 (0)