diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-02-06 17:30:31 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-02-06 17:30:31 +0100 |
commit | aad5f9d79a2b71e9d2581eace3652be156102b9d (patch) | |
tree | cb56b72a943e0bd284e68179332e05dc6f778e11 /src/ex_cmds.c | |
parent | efa1923565f0669d5bc09714b22a3b50cde03785 (diff) |
patch 8.2.2472: crash when using command line window in an autocommandv8.2.2472
Problem: Crash when using command line window in an autocommand.
(houyunsong)
Solution: Save and restore au_new_curbuf.
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r-- | src/ex_cmds.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c index b6e1cbf7f0..90a9403ff3 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -2710,8 +2710,9 @@ do_ecmd( */ if (buf != curbuf) { + bufref_T save_au_new_curbuf; #ifdef FEAT_CMDWIN - int save_cmdwin_type = cmdwin_type; + int save_cmdwin_type = cmdwin_type; // BufLeave applies to the old buffer. cmdwin_type = 0; @@ -2728,6 +2729,7 @@ do_ecmd( */ if (buf->b_fname != NULL) new_name = vim_strsave(buf->b_fname); + save_au_new_curbuf = au_new_curbuf; set_bufref(&au_new_curbuf, buf); apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); #ifdef FEAT_CMDWIN @@ -2737,12 +2739,14 @@ do_ecmd( { // new buffer has been deleted delbuf_msg(new_name); // frees new_name + au_new_curbuf = save_au_new_curbuf; goto theend; } #ifdef FEAT_EVAL if (aborting()) // autocmds may abort script processing { vim_free(new_name); + au_new_curbuf = save_au_new_curbuf; goto theend; } #endif @@ -2778,6 +2782,7 @@ do_ecmd( if (aborting() && curwin->w_buffer != NULL) { vim_free(new_name); + au_new_curbuf = save_au_new_curbuf; goto theend; } #endif @@ -2786,6 +2791,7 @@ do_ecmd( { // new buffer has been deleted delbuf_msg(new_name); // frees new_name + au_new_curbuf = save_au_new_curbuf; goto theend; } if (buf == curbuf) // already in new buffer @@ -2831,8 +2837,7 @@ do_ecmd( #endif } vim_free(new_name); - au_new_curbuf.br_buf = NULL; - au_new_curbuf.br_buf_free_count = 0; + au_new_curbuf = save_au_new_curbuf; } curwin->w_pcmark.lnum = 1; |