fix some acme memory leaks

(imported from plan9port 7ca1c90109e17dced4b38fbaadea9d2cf39871b7,
some tag restoration lines not relevant.)
This commit is contained in:
Ori Bernstein 2019-12-06 12:08:00 -08:00
parent 450ec696ee
commit 480d7b8f5f
2 changed files with 6 additions and 2 deletions

View file

@ -307,15 +307,18 @@ static int errorfd;
void void
acmeerrorproc(void *) acmeerrorproc(void *)
{ {
char *buf; char *buf, *s;
int n; int n;
threadsetname("acmeerrorproc"); threadsetname("acmeerrorproc");
buf = emalloc(8192+1); buf = emalloc(8192+1);
while((n=read(errorfd, buf, 8192)) >= 0){ while((n=read(errorfd, buf, 8192)) >= 0){
buf[n] = '\0'; buf[n] = '\0';
sendp(cerr, estrdup(buf)); s = estrdup(buf);
sendp(cerr, s);
free(s);
} }
free(buf);
} }
void void

View file

@ -159,6 +159,7 @@ execute(Text *t, uint aq0, uint aq1, int external, Text *argt)
aa = getbytearg(argt, TRUE, TRUE, &a); aa = getbytearg(argt, TRUE, TRUE, &a);
if(a){ if(a){
if(strlen(a) > EVENTSIZE){ /* too big; too bad */ if(strlen(a) > EVENTSIZE){ /* too big; too bad */
free(r);
free(aa); free(aa);
free(a); free(a);
warning(nil, "`argument string too long\n"); warning(nil, "`argument string too long\n");