lib/fetch/http.c: try to fix CID 62683 (resource leak)

This commit is contained in:
Juan RP 2014-10-05 10:32:09 +02:00
parent 25e8fca7b4
commit c3dc804bc0

View File

@ -815,7 +815,7 @@ fetchIO *
http_request(struct url *URL, const char *op, struct url_stat *us, http_request(struct url *URL, const char *op, struct url_stat *us,
struct url *purl, const char *flags) struct url *purl, const char *flags)
{ {
conn_t *conn; conn_t *conn = NULL;
struct url *url, *new; struct url *url, *new;
int chunked, direct, if_modified_since, need_auth, noredirect; int chunked, direct, if_modified_since, need_auth, noredirect;
int keep_alive, verbose, cached; int keep_alive, verbose, cached;
@ -869,6 +869,9 @@ http_request(struct url *URL, const char *op, struct url_stat *us,
} }
/* connect to server or proxy */ /* connect to server or proxy */
if (conn != NULL)
fetch_close(conn);
if ((conn = http_connect(url, purl, flags, &cached)) == NULL) if ((conn = http_connect(url, purl, flags, &cached)) == NULL)
goto ouch; goto ouch;