From 7ca1c90109e17dced4b38fbaadea9d2cf39871b7 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Tue, 20 Mar 2018 22:15:12 -0500 Subject: acme: fix some memory leaks --- src/cmd/acme/acme.c | 7 +++++-- src/cmd/acme/exec.c | 1 + src/cmd/acme/rows.c | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/cmd/acme') diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c index 10dcdcc8..742aabdf 100644 --- a/src/cmd/acme/acme.c +++ b/src/cmd/acme/acme.c @@ -383,7 +383,7 @@ int erroutfd; void acmeerrorproc(void *v) { - char *buf; + char *buf, *s; int n; USED(v); @@ -391,8 +391,11 @@ acmeerrorproc(void *v) buf = emalloc(8192+1); while((n=read(errorfd, buf, 8192)) >= 0){ buf[n] = '\0'; - sendp(cerr, estrdup(buf)); + s = estrdup(buf); + sendp(cerr, s); + free(s); } + free(buf); } void diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c index deaef0cb..68c5d976 100644 --- a/src/cmd/acme/exec.c +++ b/src/cmd/acme/exec.c @@ -194,6 +194,7 @@ execute(Text *t, uint aq0, uint aq1, int external, Text *argt) aa = getbytearg(argt, TRUE, TRUE, &a); if(a){ if(strlen(a) > EVENTSIZE){ /* too big; too bad */ + free(r); free(aa); free(a); warning(nil, "argument string too long\n"); diff --git a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c index 2d6cbcca..8cff0855 100644 --- a/src/cmd/acme/rows.c +++ b/src/cmd/acme/rows.c @@ -613,6 +613,7 @@ rowload(Row *row, char *file, int initing) } textdelete(&row->col[i]->tag, 0, row->col[i]->tag.file->b.nc, TRUE); textinsert(&row->col[i]->tag, 0, r+n+1, nr-(n+1), TRUE); + free(r); break; case 'w': l[Blinelen(b)-1] = 0; @@ -626,6 +627,7 @@ rowload(Row *row, char *file, int initing) } textdelete(&row->tag, 0, row->tag.file->b.nc, TRUE); textinsert(&row->tag, 0, r, nr, TRUE); + free(r); break; default: done = 1; -- cgit v1.2.3