* must be an associated call later to Curl_freeaddrinfo().
*/
-static struct Curl_addrinfo *
-doh2ai(const struct dohentry *de, const char *hostname, int port)
+static CURLcode doh2ai(const struct dohentry *de, const char *hostname,
+ int port, struct Curl_addrinfo **aip)
{
struct Curl_addrinfo *ai;
struct Curl_addrinfo *prevai = NULL;
int i;
size_t hostlen = strlen(hostname) + 1; /* include null-terminator */
- if(!de)
- /* no input == no output! */
- return NULL;
+ DEBUGASSERT(de);
+
+ if(!de->numaddr)
+ return CURLE_COULDNT_RESOLVE_HOST;
for(i = 0; i < de->numaddr; i++) {
size_t ss_size;
Curl_freeaddrinfo(firstai);
firstai = NULL;
}
+ *aip = firstai;
- return firstai;
+ return result;
}
#ifndef CURL_DISABLE_VERBOSE_STRINGS
infof(data, "DoH Host name: %s", dohp->host);
showdoh(data, &de);
- ai = doh2ai(&de, dohp->host, dohp->port);
- if(!ai) {
+ result = doh2ai(&de, dohp->host, dohp->port, &ai);
+ if(result) {
de_cleanup(&de);
- return CURLE_OUT_OF_MEMORY;
+ return result;
}
if(data->share)