summaryrefslogtreecommitdiff
path: root/src/reqs.c
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2002-04-18 17:58:52 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2002-04-18 17:58:52 +0000
commita66aae880c04355eac54f27fdb4c3e2a993e5f6e (patch)
tree2d5928fb47ccf6ce9733d4dd40fc2b50db3abbfa /src/reqs.c
parent3b5a4b736257f17756b713f4e8a3974a81f099ca (diff)
downloadtinyproxy-a66aae880c04355eac54f27fdb4c3e2a993e5f6e.tar.gz
tinyproxy-a66aae880c04355eac54f27fdb4c3e2a993e5f6e.zip
Fixed a memory leak in reading in headers from the client or server.
Diffstat (limited to '')
-rw-r--r--src/reqs.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/reqs.c b/src/reqs.c
index 1d77952..a586dc6 100644
--- a/src/reqs.c
+++ b/src/reqs.c
@@ -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
* connections have a new thread created for them. The thread then
@@ -546,18 +546,26 @@ get_all_headers(int fd, hashmap_t hashofheaders)
ssize_t len;
for (;;) {
- if ((len = readline(fd, &header)) <= 0)
+ if ((len = readline(fd, &header)) <= 0) {
+ safefree(header);
return -1;
+ }
/*
* If we received just a CR LF on a line, the headers are
* finished.
*/
- if (CHECK_CRLF(header, len))
+ if (CHECK_CRLF(header, len)) {
+ safefree(header);
return 0;
+ }
- if (add_header_to_connection(hashofheaders, header, len) < 0)
+ if (add_header_to_connection(hashofheaders, header, len) < 0) {
+ safefree(header);
return -1;
+ }
+
+ safefree(header);
}
}