From b08660e1fd6935c2b79528fe3c776660474d77c6 Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Thu, 31 Dec 2015 19:35:26 +0000 Subject: [PATCH] ed: Fix infinite recursion to undo() --- ed.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ed.c b/ed.c index 8903957..623c6b4 100644 --- a/ed.c +++ b/ed.c @@ -282,7 +282,7 @@ undo(void) struct link *p; if (udata.nr == 0) - error("nothing to undo"); + return; for (p = &udata.vec[udata.nr-1]; udata.nr--; --p) { zero[p->from1].next = p->to1; zero[p->from2].prev = p->to2; @@ -1101,6 +1101,8 @@ repeat: if (nlines > 0) goto bad_address; chkprint(1); + if (udata.nr == 0) + error("nothing to undo"); undo(); break; case 's':