diff --git a/src/global.c b/src/global.c
index 969218d80bf3f8e1c91a8509a1a6f5c5df34b170..6e1400605cdf53d208d5e1073abd0e9253312cde 100644
--- a/src/global.c
+++ b/src/global.c
@@ -25,9 +25,12 @@
 
 /* Global variables. */
 #ifndef NANO_TINY
-sigjmp_buf jmpbuf;
+sigjmp_buf jump_buf;
 	/* Used to return to main() or the unjustify routine in
 	 * do_justify() after a SIGWINCH. */
+bool jump_buf_main = FALSE;
+	/* Have we set jump_buf so that we return to main() after a
+	 * SIGWINCH? */
 #endif
 
 #ifndef DISABLE_WRAPJUSTIFY
diff --git a/src/nano.c b/src/nano.c
index 0dcdcba6ddd768fe65058e8b0144dce012cb81a9..bf6661737c63a558f664686d222e753e22a21409 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1081,8 +1081,9 @@ RETSIGTYPE handle_sigwinch(int signal)
     currshortcut = main_list;
     total_refresh();
 
-    /* Jump back to the main loop. */
-    siglongjmp(jmpbuf, 1);
+    /* Jump back to either main() or the unjustify routine in
+     * do_justify(). */
+    siglongjmp(jump_buf, 1);
 }
 
 /* If allow is TRUE, block any SIGWINCH signals that we get, so that we
@@ -2134,8 +2135,14 @@ int main(int argc, char **argv)
 	reset_cursor();
 
 #ifndef NANO_TINY
-	/* Return here after a SIGWINCH. */
-	sigsetjmp(jmpbuf, 1);
+	if (!jump_buf_main) {
+	    /* If we haven't already, we're going to set jump_buf so
+	     * that we return here after a SIGWINCH.  Indicate this. */
+	    jump_buf_main = TRUE;
+
+	    /* Return here after a SIGWINCH. */
+	    sigsetjmp(jump_buf, 1);
+	}
 #endif
 
 	/* If constant cursor position display is on, and there are no
diff --git a/src/proto.h b/src/proto.h
index 0552a3ab4b3c5ea492fc92473d4604df57e94a3d..c8054a5b629fb5cba8a70aa93ff3bcefe4cb95e0 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -28,7 +28,8 @@
 
 /* Public externs.  See global.c for descriptions of them. */
 #ifndef NANO_TINY
-extern sigjmp_buf jmpbuf;
+extern sigjmp_buf jump_buf;
+extern bool jump_buf_main;
 #endif
 
 #ifndef DISABLE_WRAPJUSTIFY
diff --git a/src/text.c b/src/text.c
index 4b6fa325b4202f7e9cd5a9aff86b336943e738a9..1c1727ec8a3ab854f536facee3d6062a9a839d9b 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1656,8 +1656,12 @@ void do_justify(bool full_justify)
     edit_refresh();
 
 #ifndef NANO_TINY
+    /* We're going to set jump_buf so that we return here after a
+     * SIGWINCH instead of to main().  Indicate this. */
+    jump_buf_main = FALSE;
+
     /* Return here after a SIGWINCH. */
-    sigsetjmp(jmpbuf, 1);
+    sigsetjmp(jump_buf, 1);
 #endif
 
     statusbar(_("Can now UnJustify!"));