1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Do not free request in establish_connection; do it in gethttp

* src/http.c (establish_connection): Do not free request here (it is
* never allocated here).
* src/http.c (gethttp): Free request before returning if error in
* establish_connection encountered.
This commit is contained in:
Hubert Tarasiuk 2015-03-29 00:09:22 +01:00 committed by Giuseppe Scrivano
parent 621c313b94
commit 045463b814

View File

@ -1868,7 +1868,6 @@ establish_connection (struct url *u, struct url **conn_ref,
} }
else if (host_lookup_failed) else if (host_lookup_failed)
{ {
request_free (req);
logprintf(LOG_NOTQUIET, logprintf(LOG_NOTQUIET,
_("%s: unable to resolve host address %s\n"), _("%s: unable to resolve host address %s\n"),
exec_name, quote (relevant->host)); exec_name, quote (relevant->host));
@ -1884,16 +1883,10 @@ establish_connection (struct url *u, struct url **conn_ref,
{ {
sock = connect_to_host (conn->host, conn->port); sock = connect_to_host (conn->host, conn->port);
if (sock == E_HOST) if (sock == E_HOST)
{
request_free (req);
return HOSTERR; return HOSTERR;
}
else if (sock < 0) else if (sock < 0)
{
request_free (req);
return (retryable_socket_connect_error (errno) return (retryable_socket_connect_error (errno)
? CONERROR : CONIMPOSSIBLE); ? CONERROR : CONIMPOSSIBLE);
}
#ifdef HAVE_SSL #ifdef HAVE_SSL
if (proxy && u->scheme == SCHEME_HTTPS) if (proxy && u->scheme == SCHEME_HTTPS)
@ -1923,7 +1916,6 @@ establish_connection (struct url *u, struct url **conn_ref,
if (write_error < 0) if (write_error < 0)
{ {
CLOSE_INVALIDATE (sock); CLOSE_INVALIDATE (sock);
request_free (req);
return WRITEFAILED; return WRITEFAILED;
} }
@ -1933,7 +1925,6 @@ establish_connection (struct url *u, struct url **conn_ref,
logprintf (LOG_VERBOSE, _("Failed reading proxy response: %s\n"), logprintf (LOG_VERBOSE, _("Failed reading proxy response: %s\n"),
fd_errstr (sock)); fd_errstr (sock));
CLOSE_INVALIDATE (sock); CLOSE_INVALIDATE (sock);
request_free (req);
return HERR; return HERR;
} }
message = NULL; message = NULL;
@ -1954,7 +1945,6 @@ establish_connection (struct url *u, struct url **conn_ref,
quotearg_style (escape_quoting_style, quotearg_style (escape_quoting_style,
_("Malformed status line"))); _("Malformed status line")));
xfree (head); xfree (head);
request_free (req);
return HERR; return HERR;
} }
xfree(hs->message); xfree(hs->message);
@ -1967,7 +1957,6 @@ establish_connection (struct url *u, struct url **conn_ref,
logprintf (LOG_NOTQUIET, _("Proxy tunneling failed: %s"), logprintf (LOG_NOTQUIET, _("Proxy tunneling failed: %s"),
message ? quotearg_style (escape_quoting_style, message) : "?"); message ? quotearg_style (escape_quoting_style, message) : "?");
xfree (message); xfree (message);
request_free (req);
return CONSSLERR; return CONSSLERR;
} }
xfree (message); xfree (message);
@ -1983,13 +1972,11 @@ establish_connection (struct url *u, struct url **conn_ref,
if (!ssl_connect_wget (sock, u->host)) if (!ssl_connect_wget (sock, u->host))
{ {
CLOSE_INVALIDATE (sock); CLOSE_INVALIDATE (sock);
request_free (req);
return CONSSLERR; return CONSSLERR;
} }
else if (!ssl_check_certificate (sock, u->host)) else if (!ssl_check_certificate (sock, u->host))
{ {
CLOSE_INVALIDATE (sock); CLOSE_INVALIDATE (sock);
request_free (req);
return VERIFCERTERR; return VERIFCERTERR;
} }
*using_ssl = true; *using_ssl = true;
@ -2501,8 +2488,11 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
uerr_t err = establish_connection (u, &conn, hs, proxy, &proxyauth, &req, uerr_t err = establish_connection (u, &conn, hs, proxy, &proxyauth, &req,
&using_ssl, inhibit_keep_alive, &sock); &using_ssl, inhibit_keep_alive, &sock);
if (err != RETROK) if (err != RETROK)
{
request_free (req);
return err; return err;
} }
}
/* Open the temporary file where we will write the request. */ /* Open the temporary file where we will write the request. */