aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDane Summers <dsummersl@yahoo.com>2014-04-30 08:20:27 -0400
committerJustin M. Keyes <justinkz@gmail.com>2014-05-06 13:53:22 -0400
commit85459327ba76d674572ad96dc459c97e4a71e88d (patch)
treeb6cb1102437000ea14ee8a8b041f62018bcf4256
parentd910ef2099f476ab2564d7c9ba2a33dc797b6385 (diff)
downloadrneovim-85459327ba76d674572ad96dc459c97e4a71e88d.tar.gz
rneovim-85459327ba76d674572ad96dc459c97e4a71e88d.tar.bz2
rneovim-85459327ba76d674572ad96dc459c97e4a71e88d.zip
Prevent preserve_exit() from executing more than once.
https://github.com/neovim/neovim/issues/563
-rw-r--r--src/misc1.c9
-rw-r--r--src/os/signal.c3
2 files changed, 7 insertions, 5 deletions
diff --git a/src/misc1.c b/src/misc1.c
index 3f8a1b934a..dbe4064b47 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -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();
diff --git a/src/os/signal.c b/src/os/signal.c
index 87eb379014..d3bedad09c 100644
--- a/src/os/signal.c
+++ b/src/os/signal.c
@@ -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();
}