commit b08660e1fd6935c2b79528fe3c776660474d77c6
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Thu Dec 31 19:35:26 2015 +0000
Commit:     sin <[email protected]>
CommitDate: Thu Dec 31 19:38:17 2015 +0000

    ed: Fix infinite recursion to undo()

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':

Reply via email to