File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed
Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -3775,7 +3775,7 @@ free_all_options(void)
37753775 if (options [i ].indir == PV_NONE )
37763776 {
37773777 /* global option: free value and default value. */
3778- if (options [i ].flags & P_ALLOCED && options [i ].var != NULL )
3778+ if (( options [i ].flags & P_ALLOCED ) && options [i ].var != NULL )
37793779 free_string_option (* (char_u * * )options [i ].var );
37803780 if (options [i ].flags & P_DEF_ALLOCED )
37813781 free_string_option (options [i ].def_val [VI_DEFAULT ]);
@@ -5929,8 +5929,14 @@ did_set_string_option(
59295929 else if (set_termname (T_NAME ) == FAIL )
59305930 errmsg = (char_u * )N_ ("E522: Not found in termcap" );
59315931 else
5932+ {
59325933 /* Screen colors may have changed. */
59335934 redraw_later_clear ();
5935+
5936+ /* Both 'term' and 'ttytype' point to T_NAME, only set the
5937+ * P_ALLOCED flag on 'term'. */
5938+ opt_idx = findoption ((char_u * )"term" );
5939+ }
59345940 }
59355941
59365942 /* 'backupcopy' */
Original file line number Diff line number Diff line change @@ -235,3 +235,22 @@ func Test_set_errors()
235235 call assert_fails (" set showbreak=\x01 " , ' E595:' )
236236 call assert_fails (' set t_foo=' , ' E846:' )
237237endfunc
238+
239+ func Test_set_ttytype ()
240+ if ! has (' gui_running' ) && has (' unix' )
241+ " Setting 'ttytype' used to cause a double-free when exiting vim and
242+ " when vim is compiled with -DEXITFREE.
243+ set ttytype = ansi
244+ call assert_equal (' ansi' , &ttytype )
245+ call assert_equal (&ttytype , &term )
246+ set ttytype = xterm
247+ call assert_equal (' xterm' , &ttytype )
248+ call assert_equal (&ttytype , &term )
249+ " FIXME: "set ttytype=" gives E522 instead of E529
250+ " in travis on some builds. Why? Commented out this test for now.
251+ " call assert_fails('set ttytype=', 'E529:')
252+ call assert_fails (' set ttytype=xxx' , ' E522:' )
253+ set ttytype &
254+ call assert_equal (&ttytype , &term )
255+ endif
256+ endfunc
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+ 342 ,
767769/**/
768770 341 ,
769771/**/
You can’t perform that action at this time.
0 commit comments