← Commit list

f6bbc2b3be

x2018
x2018
2025-11-01
SUCCESS Duration: 302s

Subject

doh: cleanup resources on error paths

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/doh.c+13 -14
@@ -1219,8 +1219,9 @@ UNITTEST void doh_print_httpsrr(struct Curl_easy *data,
CURLcode Curl_doh_is_resolved(struct Curl_easy *data,
struct Curl_dns_entry **dnsp)
{
- CURLcode result;
+ CURLcode result = CURLE_OK;
struct doh_probes *dohp = data->state.async.doh;
+ struct dohentry de;
*dnsp = NULL; /* defaults to no response */
if(!dohp)
return CURLE_OUT_OF_MEMORY;
@@ -1233,7 +1234,6 @@ CURLcode Curl_doh_is_resolved(struct Curl_easy *data,
}
else if(!dohp->pending) {
DOHcode rc[DOH_SLOT_COUNT];
- struct dohentry de;
int slot;
/* Clear any result the might still be there */
@@ -1265,17 +1265,14 @@ CURLcode Curl_doh_is_resolved(struct Curl_easy *data,
struct Curl_dns_entry *dns;
struct Curl_addrinfo *ai;
-
if(Curl_trc_ft_is_verbose(data, &Curl_trc_feat_dns)) {
CURL_TRC_DNS(data, "hostname: %s", dohp->host);
doh_show(data, &de);
}
result = doh2ai(&de, dohp->host, dohp->port, &ai);
- if(result) {
- de_cleanup(&de);
- return result;
- }
+ if(result)
+ goto error;
/* we got a response, create a dns entry. */
dns = Curl_dnscache_mk_entry(data, ai, dohp->host, 0, dohp->port, FALSE);
@@ -1288,7 +1285,8 @@ CURLcode Curl_doh_is_resolved(struct Curl_easy *data,
de.https_rrs->len, &hrr);
if(result) {
infof(data, "Failed to decode HTTPS RR");
- return result;
+ Curl_resolv_unlink(data, &dns);
+ goto error;
}
infof(data, "Some HTTPS RR to process");
# ifdef DEBUGBUILD
@@ -1306,14 +1304,15 @@ CURLcode Curl_doh_is_resolved(struct Curl_easy *data,
/* All done */
data->state.async.done = TRUE;
- de_cleanup(&de);
- Curl_doh_cleanup(data);
- return result;
-
} /* !dohp->pending */
+ else
+ /* wait for pending DoH transactions to complete */
+ return CURLE_OK;
- /* else wait for pending DoH transactions to complete */
- return CURLE_OK;
+error:
+ de_cleanup(&de);
+ Curl_doh_cleanup(data);
+ return result;
}
void Curl_doh_close(struct Curl_easy *data)