diff --git a/lib/easy.c b/lib/easy.c index 6195d21e30a869e66b0099b2562a94dfc81afa7c..939966dde831e8b0222de3cba964824d8a40f511 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -397,7 +397,10 @@ CURLcode curl_easy_perform(CURL *easy) mcode = curl_multi_add_handle(multi, easy); if(mcode) { curl_multi_cleanup(multi); - return CURLE_FAILED_INIT; + if(mcode == CURLM_OUT_OF_MEMORY) + return CURLE_OUT_OF_MEMORY; + else + return CURLE_FAILED_INIT; } /* we start some action by calling perform right away */ diff --git a/lib/url.c b/lib/url.c index edbd1157c47e0bf2e9bbf4e2c559751435ec2964..3b6e56642072b6135e4a27cecaba868edfb32385 100644 --- a/lib/url.c +++ b/lib/url.c @@ -501,6 +501,9 @@ CURLcode Curl_open(struct SessionHandle **curl) { CURLcode res = CURLE_OK; struct SessionHandle *data; +#ifdef USE_ARES + int status; +#endif /* Very simple start-up: alloc the struct, init it with zeroes and return */ data = (struct SessionHandle *)calloc(1, sizeof(struct SessionHandle)); @@ -513,10 +516,13 @@ CURLcode Curl_open(struct SessionHandle **curl) data->magic = CURLEASY_MAGIC_NUMBER; #ifdef USE_ARES - if(ARES_SUCCESS != ares_init(&data->state.areschannel)) { + if ((status = ares_init(&data->state.areschannel)) != ARES_SUCCESS) { DEBUGF(fprintf(stderr, "Error: ares_init failed\n")); free(data); - return CURLE_FAILED_INIT; + if (status == ARES_ENOMEM) + return CURLE_OUT_OF_MEMORY; + else + return CURLE_FAILED_INIT; } /* make sure that all other returns from this function should destroy the ares channel before returning error! */