diff --git a/src/nano.c b/src/nano.c
index 69481ea34f17ea3c5dee4a61d9e4f93dcfb15683..2398d91c9b38f67de942f72c5d19555397317ce7 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1211,6 +1211,16 @@ void signal_init(void)
 		sigaction(SIGTSTP, &act, NULL);
 #endif
 	}
+
+#ifndef DEBUG
+	/* Trap SIGSEGV and SIGABRT to save any changed buffers and reset
+	 * the terminal to a usable state.  Reset these handlers to their
+	 * defaults as soon as their signal fires. */
+	act.sa_handler = handle_crash;
+	act.sa_flags |= SA_RESETHAND;
+	sigaction(SIGSEGV, &act, NULL);
+	sigaction(SIGABRT, &act, NULL);
+#endif
 }
 
 /* Handler for SIGHUP (hangup) and SIGTERM (terminate). */
@@ -1219,6 +1229,14 @@ RETSIGTYPE handle_hupterm(int signal)
 	die(_("Received SIGHUP or SIGTERM\n"));
 }
 
+#ifndef DEBUG
+/* Handler for SIGSEGV (segfault) and SIGABRT (abort). */
+RETSIGTYPE handle_crash(int signal)
+{
+	die(_("Sorry! Nano crashed!  Code: %d.  Please report a bug.\n"), signal);
+}
+#endif
+
 /* Handler for SIGTSTP (suspend). */
 RETSIGTYPE do_suspend(int signal)
 {
diff --git a/src/proto.h b/src/proto.h
index f2c51f93dbc97a2693b93ac81fbfa07bb533b5e0..440af6a052fb04aec85e7a42668cf9c110f29c1c 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -426,6 +426,9 @@ void window_init(void);
 void do_exit(void);
 void close_and_go(void);
 RETSIGTYPE handle_hupterm(int signal);
+#ifndef DEBUG
+RETSIGTYPE handle_crash(int signal);
+#endif
 RETSIGTYPE do_suspend(int signal);
 RETSIGTYPE do_continue(int signal);
 #ifndef NANO_TINY