From: Daniel Stenberg Date: Thu, 18 Feb 2021 22:24:30 +0000 (+0100) Subject: url: fix memory leak if OOM in the HSTS handling X-Git-Tag: curl-7_76_0~136 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d25c479e8405dd255276a3345c8b1ae11d9419e1;p=thirdparty%2Fcurl.git url: fix memory leak if OOM in the HSTS handling Reported-by: Viktor Szakats Bug: https://github.com/curl/curl/pull/6627#issuecomment-781626205 Closes #6628 --- diff --git a/lib/url.c b/lib/url.c index e956121054..480c94c203 100644 --- a/lib/url.c +++ b/lib/url.c @@ -1959,8 +1959,10 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, if(uc) return Curl_uc_to_curlcode(uc); uc = curl_url_get(uh, CURLUPART_SCHEME, &data->state.up.scheme, 0); - if(uc) + if(uc) { + free(url); return Curl_uc_to_curlcode(uc); + } data->change.url = url; data->change.url_alloc = TRUE; infof(data, "Switched from HTTP to HTTPS due to HSTS => %s\n",