diff --git a/src/ftp.c b/src/ftp.c index 054cb615..d614a275 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -1560,6 +1560,7 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_fi else { /* URL-derived file. Consider "-O file" name. */ + xfree (con->target); con->target = url_file_name (u, NULL); if (!opt.output_document) locf = con->target; diff --git a/src/http.c b/src/http.c index 4b99c17d..5ac69d0d 100644 --- a/src/http.c +++ b/src/http.c @@ -1756,7 +1756,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy, hs->res = -1; hs->rderrmsg = NULL; hs->newloc = NULL; - hs->remote_time = NULL; + xfree(hs->remote_time); hs->remote_time = NULL; hs->error = NULL; hs->message = NULL; @@ -1868,6 +1868,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy, { logprintf (LOG_NOTQUIET, _("BODY data file %s missing: %s\n"), quote (opt.body_file), strerror (errno)); + request_free (req); return FILEBADFILE; } } diff --git a/src/init.c b/src/init.c index 3bdaa486..ef1dc8d7 100644 --- a/src/init.c +++ b/src/init.c @@ -69,6 +69,7 @@ as that of the covered work. */ #include "retr.h" /* for output_stream */ #include "warc.h" /* for warc_close */ #include "spider.h" /* for spider_cleanup */ +#include "html-url.h" /* for cleanup_html_url */ #ifdef TESTING #include "test.h" @@ -1747,10 +1748,7 @@ cleanup (void) spider_cleanup (); host_cleanup (); log_cleanup (); - netrc_cleanup (netrc_list); - - for (i = 0; i < nurl; i++) - xfree (url[i]); + netrc_cleanup (); xfree_null (opt.choose_config); xfree_null (opt.lfilename); @@ -1759,8 +1757,8 @@ cleanup (void) xfree_null (opt.output_document); free_vec (opt.accepts); free_vec (opt.rejects); - free_vec (opt.excludes); - free_vec (opt.includes); + free_vec ((char **)opt.excludes); + free_vec ((char **)opt.includes); free_vec (opt.domains); free_vec (opt.follow_tags); free_vec (opt.ignore_tags); @@ -1792,6 +1790,10 @@ cleanup (void) xfree_null (opt.passwd); xfree_null (opt.base_href); xfree_null (opt.method); + xfree_null (opt.post_file_name); + xfree_null (opt.post_data); + xfree_null (opt.body_data); + xfree_null (opt.body_file); #endif /* DEBUG_MALLOC */ } diff --git a/src/main.c b/src/main.c index 1ada8221..4fefe049 100644 --- a/src/main.c +++ b/src/main.c @@ -1455,11 +1455,13 @@ for details.\n\n")); if (opt.post_data) { setoptval ("bodydata", opt.post_data, "body-data"); + xfree(opt.post_data); opt.post_data = NULL; } else { setoptval ("bodyfile", opt.post_file_name, "body-file"); + xfree(opt.post_file_name); opt.post_file_name = NULL; } } diff --git a/src/retr.c b/src/retr.c index 71b5c288..ff5f5b3c 100644 --- a/src/retr.c +++ b/src/retr.c @@ -761,7 +761,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file, pi->utf8_encode = false; /* Parse the proxy URL. */ - proxy_url = url_parse (proxy, &up_error_code, NULL, true); + proxy_url = url_parse (proxy, &up_error_code, pi, true); if (!proxy_url) { char *error = url_error (proxy, up_error_code); @@ -782,6 +782,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file, result = PROXERR; goto bail; } + iri_free(pi); free (proxy); } @@ -930,6 +931,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file, if (u) { DEBUGP (("[IRI fallbacking to non-utf8 for %s\n", quote (url))); + xfree (url); url = xstrdup (u->url); iri_fallbacked = 1; goto redirected; diff --git a/src/url.c b/src/url.c index 0551c582..3e1f6649 100644 --- a/src/url.c +++ b/src/url.c @@ -705,6 +705,7 @@ url_parse (const char *url, int *error, struct iri *iri, bool percent_encode) new_url = NULL; else { + xfree_null (iri->orig_url); iri->orig_url = xstrdup (url); url_encoded = reencode_escapes (new_url); if (url_encoded != new_url)