ed: Fix double-free

After join() is called for the first time, s.str is left pointing
to a string that was just freed. Upon the second call to join(),
it is freed again at the start of the function.

Since the string is reset on every function call, there is no reason
for it to be static, so just replace the initial free with assignment
to NULL.
master
Cág 2 years ago committed by Michael Forney
parent 172cdd98c3
commit 3eb89c44aa

@ -839,9 +839,9 @@ join(void)
{
int i;
char *t, c;
static String s;
String s;
free(s.str);
s.str = NULL;
s.siz = s.cap = 0;
for (i = line1;; i = nextln(i)) {
for (t = gettxt(i); (c = *t) != '\n'; ++t)

Loading…
Cancel
Save