Skip to content

Commit

Permalink
acme: fix double-free in acmeerrorproc
Browse files Browse the repository at this point in the history
The receiver of cerr takes ownership of s.
  • Loading branch information
rsc committed Mar 23, 2021
1 parent 9097137 commit 7366140
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/cmd/acme/acme.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,17 +383,15 @@ int erroutfd;
void
acmeerrorproc(void *v)
{
char *buf, *s;
char *buf;
int n;

USED(v);
threadsetname("acmeerrorproc");
buf = emalloc(8192+1);
while((n=read(errorfd, buf, 8192)) >= 0){
buf[n] = '\0';
s = estrdup(buf);
sendp(cerr, s);
free(s);
sendp(cerr, estrdup(buf));
}
free(buf);
}
Expand Down

0 comments on commit 7366140

Please sign in to comment.