Fixed a memory leak in reading in headers from the client or server.

This commit is contained in:
Robert James Kaes 2002-04-18 17:58:52 +00:00
parent 3b5a4b7362
commit a66aae880c

View File

@ -1,4 +1,4 @@
/* $Id: reqs.c,v 1.61 2002-04-17 20:55:21 rjkaes Exp $ /* $Id: reqs.c,v 1.62 2002-04-18 17:58:52 rjkaes Exp $
* *
* This is where all the work in tinyproxy is actually done. Incoming * This is where all the work in tinyproxy is actually done. Incoming
* connections have a new thread created for them. The thread then * connections have a new thread created for them. The thread then
@ -546,19 +546,27 @@ get_all_headers(int fd, hashmap_t hashofheaders)
ssize_t len; ssize_t len;
for (;;) { for (;;) {
if ((len = readline(fd, &header)) <= 0) if ((len = readline(fd, &header)) <= 0) {
safefree(header);
return -1; return -1;
}
/* /*
* If we received just a CR LF on a line, the headers are * If we received just a CR LF on a line, the headers are
* finished. * finished.
*/ */
if (CHECK_CRLF(header, len)) if (CHECK_CRLF(header, len)) {
safefree(header);
return 0; return 0;
}
if (add_header_to_connection(hashofheaders, header, len) < 0) if (add_header_to_connection(hashofheaders, header, len) < 0) {
safefree(header);
return -1; return -1;
} }
safefree(header);
}
} }
/* /*