[hackers] [PATCH 01/17] Set restore point before seeting signal handlers

From: quinq <quinq_AT_fifth.space>
Date: Tue, 6 Mar 2018 12:57:53 +0100

From: "Roberto E. Vargas Caballero" <k0ga_AT_shike2.com>

---
 ed.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/ed.c b/ed.c
index 2a84b60..5511a9e 100644
--- a/ed.c
+++ b/ed.c
_AT_@ -1368,7 +1368,6 @@ sighup(int dummy)
 static void
 edit(void)
 {
-	setjmp(savesp);
 	for (;;) {
 		newcmd = 1;
 		ocurln = curln;
_AT_@ -1388,8 +1387,6 @@ init(char *fname)
 {
 	size_t len;
 
-	if (setjmp(savesp))
-		return;
 	setscratch();
 	if (!fname)
 		return;
_AT_@ -1418,11 +1415,12 @@ main(int argc, char *argv[])
 	if (argc > 1)
 		usage();
 
-	signal(SIGINT, sigintr);
-	signal(SIGHUP, sighup);
-	signal(SIGQUIT, SIG_IGN);
-
-	init(*argv);
+	if (!setjmp(savesp)) {
+		signal(SIGINT, sigintr);
+		signal(SIGHUP, sighup);
+		signal(SIGQUIT, SIG_IGN);
+		init(*argv);
+	}
 	edit();
 
 	/* not reached */
-- 
2.14.2
Received on Tue Mar 06 2018 - 12:57:53 CET

This archive was generated by hypermail 2.3.0 : Tue Mar 06 2018 - 13:01:10 CET