summaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-02-18 23:24:30 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-02-19 08:05:40 +0100
commitd25c479e8405dd255276a3345c8b1ae11d9419e1 (patch)
tree89c6ed984a59f0b51997caf13a155d27b673f796 /lib/url.c
parente06fa7462ac258cf6096a0c909310bf23cf7c1eb (diff)
downloadcurl-d25c479e8405dd255276a3345c8b1ae11d9419e1.tar.gz
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
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/url.c b/lib/url.c
index e95612105..480c94c20 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",