Prevent preserve_exit() from executing more than once.

https://github.com/neovim/neovim/issues/563
This commit is contained in:
Dane Summers 2014-04-30 08:20:27 -04:00 committed by Justin M. Keyes
parent d910ef2099
commit 85459327ba
2 changed files with 7 additions and 5 deletions

View File

@ -3373,12 +3373,15 @@ void preserve_exit(void)
{
buf_T *buf;
prepare_to_exit();
// Prevent repeated calls into this method.
if (really_exiting) {
exit(2);
}
/* Setting this will prevent free() calls. That avoids calling free()
* recursively when free() was invoked with a bad pointer. */
really_exiting = TRUE;
prepare_to_exit();
out_str(IObuff);
screen_start(); /* don't know where cursor is now */
out_flush();

View File

@ -139,8 +139,7 @@ static void deadly_signal(int signum)
snprintf((char *)IObuff, sizeof(IObuff), "Vim: Caught deadly signal '%s'\n",
signal_name(signum));
// Preserve files and exit. This sets the really_exiting flag to prevent
// calling free().
// Preserve files and exit.
preserve_exit();
}