ed: Fix infinite recursion to undo()

This commit is contained in:
Roberto E. Vargas Caballero 2015-12-31 19:35:26 +00:00 committed by sin
parent a02d66b8fc
commit b08660e1fd

4
ed.c
View File

@ -282,7 +282,7 @@ undo(void)
struct link *p; struct link *p;
if (udata.nr == 0) if (udata.nr == 0)
error("nothing to undo"); return;
for (p = &udata.vec[udata.nr-1]; udata.nr--; --p) { for (p = &udata.vec[udata.nr-1]; udata.nr--; --p) {
zero[p->from1].next = p->to1; zero[p->from1].next = p->to1;
zero[p->from2].prev = p->to2; zero[p->from2].prev = p->to2;
@ -1101,6 +1101,8 @@ repeat:
if (nlines > 0) if (nlines > 0)
goto bad_address; goto bad_address;
chkprint(1); chkprint(1);
if (udata.nr == 0)
error("nothing to undo");
undo(); undo();
break; break;
case 's': case 's':