Remove a double free() that caused joins to randomly segfault.
Fix a bug in delete() that occasionally caused lines to be
transposed.
---
 ed.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/ed.c b/ed.c
index e737d57..f6e195f 100644
--- a/ed.c
+++ b/ed.c
@@ -781,7 +781,7 @@ delete(int from, int to)
        lfrom = getindex(prevln(from));
        lto = getindex(nextln(to));
        lastln -= to - from + 1;
-       curln = (from > lastln) ? lastln : from;;
+       curln = prevln(from);
        relink(lto, lfrom, lto, lfrom);
 }
 
@@ -819,7 +819,6 @@ join(void)
        size_t len = 0, cap = 0;
        static char *s;
 
-       free(s);
        for (s = NULL, i = line1;; i = nextln(i)) {
                for (t = gettxt(i); (c = *t) != '\n'; ++t)
                        s = addchar(*t, s, &cap, &len);
-- 
2.9.0


Reply via email to