File tree Expand file tree Collapse file tree 5 files changed +26
-4
lines changed
Expand file tree Collapse file tree 5 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -2177,6 +2177,7 @@ test_arglist \
21772177 test_pyx2 \
21782178 test_pyx3 \
21792179 test_quickfix \
2180+ test_recover \
21802181 test_regexp_latin \
21812182 test_regexp_utf8 \
21822183 test_reltime \
Original file line number Diff line number Diff line change @@ -1863,8 +1863,10 @@ recover_names(
18631863 else
18641864 {
18651865#if defined(UNIX ) || defined(WIN3264 )
1866- p = dir_name + STRLEN (dir_name );
1867- if (after_pathsep (dir_name , p ) && p [-1 ] == p [-2 ])
1866+ int len = STRLEN (dir_name );
1867+
1868+ p = dir_name + len ;
1869+ if (after_pathsep (dir_name , p ) && len > 1 && p [-1 ] == p [-2 ])
18681870 {
18691871 /* Ends with '//', Use Full path for swap name */
18701872 tail = make_percent_swname (dir_name , fname_res );
@@ -3922,8 +3924,10 @@ makeswapname(
39223924#endif
39233925
39243926#if defined(UNIX ) || defined(WIN3264 ) /* Need _very_ long file names */
3925- s = dir_name + STRLEN (dir_name );
3926- if (after_pathsep (dir_name , s ) && s [-1 ] == s [-2 ])
3927+ int len = STRLEN (dir_name );
3928+
3929+ s = dir_name + len ;
3930+ if (after_pathsep (dir_name , s ) && len > 1 && s [-1 ] == s [-2 ])
39273931 { /* Ends with '//', Use Full path */
39283932 r = NULL ;
39293933 if ((s = make_percent_swname (dir_name , fname )) != NULL )
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ source test_messages.vim
3434source test_partial.vim
3535source test_popup.vim
3636source test_put.vim
37+ source test_recover.vim
3738source test_reltime.vim
3839source test_searchpos.vim
3940source test_set.vim
Original file line number Diff line number Diff line change 1+ " Test :recover
2+
3+ func Test_recover_root_dir ()
4+ " This used to access invalid memory.
5+ split Xtest
6+ set dir = /
7+ call assert_fails (' recover' , ' E305:' )
8+ close !
9+
10+ call assert_fails (' split Xtest' , ' E303:' )
11+ set dir &
12+ endfunc
13+
14+ " TODO: move recover tests from test78.in to here.
Original file line number Diff line number Diff line change @@ -764,6 +764,8 @@ static char *(features[]) =
764764
765765static int included_patches [] =
766766{ /* Add new patch number below this line */
767+ /**/
768+ 337 ,
767769/**/
768770 336 ,
769771/**/
You can’t perform that action at this time.
0 commit comments