mirror of
https://github.com/moparisthebest/curl
synced 2025-01-10 21:48:10 -05:00
fix out of memory handling issue
This commit is contained in:
parent
c518c52aba
commit
0e05a6329a
@ -397,6 +397,9 @@ CURLcode curl_easy_perform(CURL *easy)
|
|||||||
mcode = curl_multi_add_handle(multi, easy);
|
mcode = curl_multi_add_handle(multi, easy);
|
||||||
if(mcode) {
|
if(mcode) {
|
||||||
curl_multi_cleanup(multi);
|
curl_multi_cleanup(multi);
|
||||||
|
if(mcode == CURLM_OUT_OF_MEMORY)
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
else
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,6 +501,9 @@ CURLcode Curl_open(struct SessionHandle **curl)
|
|||||||
{
|
{
|
||||||
CURLcode res = CURLE_OK;
|
CURLcode res = CURLE_OK;
|
||||||
struct SessionHandle *data;
|
struct SessionHandle *data;
|
||||||
|
#ifdef USE_ARES
|
||||||
|
int status;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Very simple start-up: alloc the struct, init it with zeroes and return */
|
/* Very simple start-up: alloc the struct, init it with zeroes and return */
|
||||||
data = (struct SessionHandle *)calloc(1, sizeof(struct SessionHandle));
|
data = (struct SessionHandle *)calloc(1, sizeof(struct SessionHandle));
|
||||||
@ -513,9 +516,12 @@ CURLcode Curl_open(struct SessionHandle **curl)
|
|||||||
data->magic = CURLEASY_MAGIC_NUMBER;
|
data->magic = CURLEASY_MAGIC_NUMBER;
|
||||||
|
|
||||||
#ifdef USE_ARES
|
#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"));
|
DEBUGF(fprintf(stderr, "Error: ares_init failed\n"));
|
||||||
free(data);
|
free(data);
|
||||||
|
if (status == ARES_ENOMEM)
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
else
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
}
|
}
|
||||||
/* make sure that all other returns from this function should destroy the
|
/* make sure that all other returns from this function should destroy the
|
||||||
|
Loading…
Reference in New Issue
Block a user