ref: 480d7b8f5f0ccb52391c41ffa58c196618827346
parent: 450ec696ee46f79159395a89c9a97bc8354616ba
author: Ori Bernstein <[email protected]>
date: Fri Dec 6 07:08:00 EST 2019
fix some acme memory leaks (imported from plan9port 7ca1c90109e17dced4b38fbaadea9d2cf39871b7, some tag restoration lines not relevant.)
--- a/sys/src/cmd/acme/acme.c
+++ b/sys/src/cmd/acme/acme.c
@@ -307,7 +307,7 @@
void
acmeerrorproc(void *)
{
- char *buf;
+ char *buf, *s;
int n;
threadsetname("acmeerrorproc");
@@ -314,8 +314,11 @@
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
--- a/sys/src/cmd/acme/exec.c
+++ b/sys/src/cmd/acme/exec.c
@@ -159,6 +159,7 @@
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");