Problem: using freed memory with autocmd from fuzzer. (Dhiraj Mishra,
Dominique Pelle)
Solution: Avoid using "wp" after autocommands. (closes #5041)
call StopVimInTerminal(buf)
call delete(filename)
endfunc
+
+func Test_autocmd_was_using_freed_memory()
+ pedit xx
+ n x
+ au WinEnter * quit
+ split
+ au! WinEnter
+endfunc
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2136,
/**/
2135,
/**/
#ifdef FEAT_JOB_CHANNEL
entering_window(curwin);
#endif
+ // Careful: autocommands may close the window and make "wp" invalid
if (trigger_new_autocmds)
apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf);
if (trigger_enter_autocmds)
#endif
curwin->w_redr_status = TRUE;
#ifdef FEAT_TERMINAL
- if (bt_terminal(wp->w_buffer))
+ if (bt_terminal(curwin->w_buffer))
// terminal is likely in another mode
redraw_mode = TRUE;
#endif