From 7bf59f2fa487b34258482013c90a6a5997916dc7 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 2 Jul 2014 22:19:01 +0200 Subject: [PATCH] httpc: fix some memory leaks in the error paths --- src/httpc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/httpc.c b/src/httpc.c index bf4067dc..c4938c6f 100644 --- a/src/httpc.c +++ b/src/httpc.c @@ -526,6 +526,7 @@ http_client_send( http_client_t *hc, enum http_cmd cmd, if (hc->hc_shutdown) { if (header) http_arg_flush(header); + free(wcmd); return -EIO; } @@ -535,7 +536,10 @@ http_client_send( http_client_t *hc, enum http_cmd cmd, htsbuf_queue_init(&q, 0); s = http_cmd2str(cmd); if (s == NULL) { - http_arg_flush(header); +error: + if (header) + http_arg_flush(header); + free(wcmd); return -EINVAL; } htsbuf_append(&q, s, strlen(s)); @@ -551,8 +555,7 @@ http_client_send( http_client_t *hc, enum http_cmd cmd, s = http_ver2str(hc->hc_version); if (s == NULL) { htsbuf_queue_flush(&q); - http_arg_flush(header); - return -EINVAL; + goto error; } htsbuf_append(&q, s, strlen(s)); htsbuf_append(&q, "\r\n", 2);