Mercurial > vim
comparison src/buffer.c @ 9450:073aebdba121 v7.4.2006
commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 9 15:21:02 2016 +0200
patch 7.4.2006
Problem: Crash when using tabnext in BufUnload autocmd. (Norio Takagi)
Solution: First check that the current buffer is the right one. (Hirohito
Higashi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 09 Jul 2016 15:30:05 +0200 |
parents | 1003973c99df |
children | 38e2fc4ee4ef |
comparison
equal
deleted
inserted
replaced
9449:76bbfac1cc81 | 9450:073aebdba121 |
---|---|
457 is_curbuf = (buf == curbuf); | 457 is_curbuf = (buf == curbuf); |
458 buf->b_nwindows = nwindows; | 458 buf->b_nwindows = nwindows; |
459 #endif | 459 #endif |
460 | 460 |
461 buf_freeall(buf, (del_buf ? BFA_DEL : 0) + (wipe_buf ? BFA_WIPE : 0)); | 461 buf_freeall(buf, (del_buf ? BFA_DEL : 0) + (wipe_buf ? BFA_WIPE : 0)); |
462 if ( | |
463 #ifdef FEAT_WINDOWS | |
464 win_valid(win) && | |
465 #else | |
466 win != NULL && | |
467 #endif | |
468 win->w_buffer == buf) | |
469 win->w_buffer = NULL; /* make sure we don't use the buffer now */ | |
470 | 462 |
471 #ifdef FEAT_AUTOCMD | 463 #ifdef FEAT_AUTOCMD |
472 /* Autocommands may have deleted the buffer. */ | 464 /* Autocommands may have deleted the buffer. */ |
473 if (!buf_valid(buf)) | 465 if (!buf_valid(buf)) |
474 return; | 466 return; |
475 # ifdef FEAT_EVAL | 467 # ifdef FEAT_EVAL |
476 if (aborting()) /* autocmds may abort script processing */ | 468 if (aborting()) /* autocmds may abort script processing */ |
477 return; | 469 return; |
478 # endif | 470 # endif |
479 | |
480 /* Autocommands may have opened or closed windows for this buffer. | |
481 * Decrement the count for the close we do here. */ | |
482 if (buf->b_nwindows > 0) | |
483 --buf->b_nwindows; | |
484 | 471 |
485 /* | 472 /* |
486 * It's possible that autocommands change curbuf to the one being deleted. | 473 * It's possible that autocommands change curbuf to the one being deleted. |
487 * This might cause the previous curbuf to be deleted unexpectedly. But | 474 * This might cause the previous curbuf to be deleted unexpectedly. But |
488 * in some cases it's OK to delete the curbuf, because a new one is | 475 * in some cases it's OK to delete the curbuf, because a new one is |
489 * obtained anyway. Therefore only return if curbuf changed to the | 476 * obtained anyway. Therefore only return if curbuf changed to the |
490 * deleted buffer. | 477 * deleted buffer. |
491 */ | 478 */ |
492 if (buf == curbuf && !is_curbuf) | 479 if (buf == curbuf && !is_curbuf) |
493 return; | 480 return; |
481 | |
482 if ( | |
483 #ifdef FEAT_WINDOWS | |
484 win_valid(win) && | |
485 #else | |
486 win != NULL && | |
487 #endif | |
488 win->w_buffer == buf) | |
489 win->w_buffer = NULL; /* make sure we don't use the buffer now */ | |
490 | |
491 /* Autocommands may have opened or closed windows for this buffer. | |
492 * Decrement the count for the close we do here. */ | |
493 if (buf->b_nwindows > 0) | |
494 --buf->b_nwindows; | |
494 #endif | 495 #endif |
495 | 496 |
496 /* Change directories when the 'acd' option is set. */ | 497 /* Change directories when the 'acd' option is set. */ |
497 DO_AUTOCHDIR | 498 DO_AUTOCHDIR |
498 | 499 |