From b9c9f69b43bae9d5e8fc970eeb79283dd00053c1 Mon Sep 17 00:00:00 2001 From: reyk Date: Fri, 8 Aug 2008 19:13:24 +0000 Subject: [PATCH] fix possible memleaks in chunked encoding handler --- usr.sbin/relayd/relay.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index 9796f92011b..8f47023f508 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.98 2008/08/08 18:56:05 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.99 2008/08/08 19:13:24 reyk Exp $ */ /* * Copyright (c) 2006, 2007, 2008 Reyk Floeter @@ -1191,8 +1191,10 @@ relay_read_httpchunks(struct bufferevent *bev, void *arg) relay_close(con, "invalid chunk"); return; } - if (!strlen(line)) + if (!strlen(line)) { + free(line); goto next; + } /* Read prepended chunk size in hex, ingore the trailer */ if (sscanf(line, "%lx", &lval) != 1) { @@ -1202,8 +1204,10 @@ relay_read_httpchunks(struct bufferevent *bev, void *arg) } if (relay_bufferevent_print(cre->dst, line) == -1 || - relay_bufferevent_print(cre->dst, "\r\n") == -1) + relay_bufferevent_print(cre->dst, "\r\n") == -1) { + free(line); goto fail; + } free(line); /* Last chunk is 0 bytes followed by an empty newline */ -- 2.20.1