From c5fdc4cd720b4f2f4395028c5c754d9140053cb9 Mon Sep 17 00:00:00 2001 From: Darshit Shah Date: Wed, 23 Jul 2014 22:28:36 +0530 Subject: [PATCH] Plug memory leaks --- src/ChangeLog | 8 ++++++++ src/http.c | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 38d0ce3..f677f12 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2014-07-23 Darshit Shah + + * http.c (gethttp): Fix a memory leak when retrying authorization + (gethttp): Fix memory leak when trying to parse content disposition headers + (http_loop): Assigning a new value to *local)file without freeing the old + one causes a memory leak + (http_loop): Free the HTTP message and error strings before continuing loop + 2014-07-21 Daniel Stenberg * main.c (print_help): HTTP Method is a part of the Request not Header diff --git a/src/http.c b/src/http.c index e3c105f..4b99c17 100644 --- a/src/http.c +++ b/src/http.c @@ -2423,6 +2423,7 @@ read_header: resp_free (resp); xfree (head); xfree (auth_stat); + xfree (hs->message); goto retry_with_auth; } else @@ -2474,6 +2475,8 @@ read_header: local_file)); hs->local_file = url_file_name (u, local_file); } + + xfree_null (local_file); } /* TODO: perform this check only once. */ @@ -3411,6 +3414,8 @@ Remote file exists.\n\n")); got_name = true; *dt &= ~HEAD_ONLY; count = 0; /* the retrieve count for HEAD is reset */ + xfree_null (hstat.message); + xfree_null (hstat.error); continue; } /* send_head_first */ } /* !got_head */ @@ -3558,7 +3563,10 @@ Remote file exists.\n\n")); exit: if (ret == RETROK && local_file) - *local_file = xstrdup (hstat.local_file); + { + xfree_null (*local_file); + *local_file = xstrdup (hstat.local_file); + } free_hstat (&hstat); return ret; -- 2.0.2