doh: fix memory-leak when doing a second DoH resolve

Reported-by: James Fuller
Closes #20929
This commit is contained in:
Daniel Stenberg 2026-03-15 17:04:47 +01:00
parent f50446f6da
commit 32531f20f9
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -448,6 +448,7 @@ CURLcode Curl_doh(struct Curl_easy *data, const char *hostname,
data->state.async.done = FALSE;
data->state.async.port = port;
data->state.async.ip_version = ip_version;
curlx_free(data->state.async.hostname);
data->state.async.hostname = curlx_strdup(hostname);
if(!data->state.async.hostname)
return CURLE_OUT_OF_MEMORY;