From a66aae880c04355eac54f27fdb4c3e2a993e5f6e Mon Sep 17 00:00:00 2001 From: Robert James Kaes Date: Thu, 18 Apr 2002 17:58:52 +0000 Subject: Fixed a memory leak in reading in headers from the client or server. --- src/reqs.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') 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); } } -- cgit v1.2.3