@@ -4572,6 +4572,7 @@ load_dummy_buffer(
45724572 bufref_T newbuf_to_wipe ;
45734573 int failed = TRUE;
45744574 aco_save_T aco ;
4575+ int readfile_result ;
45754576
45764577 /* Allocate a buffer without putting it in the buffer list. */
45774578 newbuf = buflist_new (NULL , NULL , (linenr_T )1 , BLN_DUMMY );
@@ -4585,6 +4586,9 @@ load_dummy_buffer(
45854586 /* need to open the memfile before putting the buffer in a window */
45864587 if (ml_open (newbuf ) == OK )
45874588 {
4589+ /* Make sure this buffer isn't wiped out by auto commands. */
4590+ ++ newbuf -> b_locked ;
4591+
45884592 /* set curwin/curbuf to buf and save a few things */
45894593 aucmd_prepbuf (& aco , newbuf );
45904594
@@ -4599,9 +4603,11 @@ load_dummy_buffer(
45994603 curbuf -> b_flags &= ~BF_DUMMY ;
46004604
46014605 newbuf_to_wipe .br_buf = NULL ;
4602- if ( readfile (fname , NULL ,
4606+ readfile_result = readfile (fname , NULL ,
46034607 (linenr_T )0 , (linenr_T )0 , (linenr_T )MAXLNUM ,
4604- NULL , READ_NEW | READ_DUMMY ) == OK
4608+ NULL , READ_NEW | READ_DUMMY );
4609+ -- newbuf -> b_locked ;
4610+ if (readfile_result == OK
46054611 && !got_int
46064612 && !(curbuf -> b_flags & BF_NEW ))
46074613 {
0 commit comments