From 177e4e58055deabae3e69b77fabfc22be28e36bf Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 30 Jun 2021 15:01:45 +0200 Subject: [PATCH] general: prevent die() from getting recursed into When something that is called from die() calls die() again, there is nothing we can do any more but give up. This would have prevented the spiralling as seen in https://savannah.gnu.org/bugs/?60853. --- src/nano.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/nano.c b/src/nano.c index e974f34b..7fe3dd21 100644 --- a/src/nano.c +++ b/src/nano.c @@ -351,6 +351,11 @@ void die(const char *msg, ...) { va_list ap; openfilestruct *firstone = openfile; + static int stabs = 0; + + /* When dying for a second time, just give up. */ + if (++stabs > 1) + exit(11); restore_terminal();