]> granicus.if.org Git - vim/commitdiff
patch 8.2.1842: crash when USE_FNAME_CASE is defined and using :browse v8.2.1842
authorBram Moolenaar <Bram@vim.org>
Tue, 13 Oct 2020 17:08:24 +0000 (19:08 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 13 Oct 2020 17:08:24 +0000 (19:08 +0200)
Problem:    Crash when USE_FNAME_CASE is defined and using :browse.
Solution:   Don't use read-only memory for ".". (Yegappan Lakshmanan,
            closes #7123)

src/ex_cmds.c
src/ex_docmd.c
src/testdir/test_edit.vim
src/version.c

index a55fae709a50ac86176a3de01d50ef47f427063e..6371eceba1c724a236a5506274d982bba28545db 100644 (file)
@@ -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
            {
index 112cb9eab97917ca11c0860ad8e96ec0d686169d..1fc67eaec7a2f3d158edd86431741851a97999d2 100644 (file)
@@ -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
        {
index 66073455752540578bfd8af8b90db6a064e366ba..ac893f39bc44637595d00d908fab3d047bda48c4 100644 (file)
@@ -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
index 6b336314e490d2f3eaf8d1c007cb593b7d508274..e32611178f428c21bde2defbb2c0c3d1cb791fb6 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1842,
 /**/
     1841,
 /**/