Fix two memory leaks noted by Coverity (CID-4694, CIT-4695) and use

SIMPLEQ_FOREACH where possible.  Patch from Arnaud Lacombe.
This commit is contained in:
tls 2007-10-17 18:43:46 +00:00
parent 663275b41c
commit 13d3c473b0
2 changed files with 8 additions and 8 deletions

View File

@ -767,10 +767,10 @@ addmerge_header(http_req *request, char *val, char *str, ssize_t len)
static char space[2] = { ' ', 0 };
/* do we exist already? */
for (hdr = SIMPLEQ_FIRST(&request->hr_headers); hdr;
hdr = SIMPLEQ_NEXT(hdr, h_next))
SIMPLEQ_FOREACH(hdr, &request->hr_headers, h_next) {
if (strcasecmp(val, hdr->h_header) == 0)
break;
}
if (hdr) {
/* yup, merge it in */
@ -883,6 +883,7 @@ process_request(http_req *request)
/* If SSL enabled cleanup SSL structure. */
ssl_destroy();
close(fd);
free(file);
}
/*

View File

@ -179,8 +179,8 @@ process_cgi(http_req *request)
for (ix = 0; ix < envpsize; ix++)
envp[ix] = NULL;
curenvp = envp;
for (headp = SIMPLEQ_FIRST(&request->hr_headers); headp;
headp = SIMPLEQ_NEXT(headp, h_next)) {
SIMPLEQ_FOREACH(headp, &request->hr_headers, h_next) {
const char *s2;
env = bozomalloc(6 + strlen(headp->h_header) + 1 +
strlen(headp->h_value));
@ -369,10 +369,9 @@ finish_cgi_output(http_req *request, int in, int nph)
if (nheaders) {
debug((DEBUG_OBESE, "process_cgi: writing delayed HTTP "
"headers .."));
for (hdr = SIMPLEQ_FIRST(&headers); hdr;
hdr = SIMPLEQ_NEXT(hdr, h_next)) {
bozoprintf("%s: %s\r\n", hdr->h_header,
hdr->h_value);
SIMPLEQ_FOREACH(hdr, &headers, h_next) {
bozoprintf("%s: %s\r\n", hdr->h_header, hdr->h_value);
free(hdr->h_value);
}
bozoflush(stdout);
}