diff options
author | Daniel Stenberg <daniel@haxx.se> | 2017-11-20 23:16:56 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2017-11-21 09:02:50 +0100 |
commit | 9554c3c6e56e23153d4e1025b62c7a6402464a7c (patch) | |
tree | 5cf7c07541e6e850c570b733df58c7ab908dd6cd /lib | |
parent | 9474a5fe11c6d9da32ad3ec49d52e72cdb6d42ce (diff) | |
download | curl-9554c3c6e56e23153d4e1025b62c7a6402464a7c.tar.gz |
Curl_open: fix OOM return error correctly
Closes #2098
Diffstat (limited to 'lib')
-rw-r--r-- | lib/url.c | 39 |
1 files changed, 19 insertions, 20 deletions
@@ -569,32 +569,31 @@ CURLcode Curl_open(struct Curl_easy **curl) DEBUGF(fprintf(stderr, "Error: malloc of buffer failed\n")); result = CURLE_OUT_OF_MEMORY; } - - Curl_mime_initpart(&data->set.mimepost, data); - - data->state.headerbuff = malloc(HEADERSIZE); - if(!data->state.headerbuff) { - DEBUGF(fprintf(stderr, "Error: malloc of headerbuff failed\n")); - result = CURLE_OUT_OF_MEMORY; - } else { - result = Curl_init_userdefined(&data->set); - - data->state.headersize = HEADERSIZE; + Curl_mime_initpart(&data->set.mimepost, data); - Curl_convert_init(data); + data->state.headerbuff = malloc(HEADERSIZE); + if(!data->state.headerbuff) { + DEBUGF(fprintf(stderr, "Error: malloc of headerbuff failed\n")); + result = CURLE_OUT_OF_MEMORY; + } + else { + result = Curl_init_userdefined(&data->set); - Curl_initinfo(data); + data->state.headersize = HEADERSIZE; + Curl_convert_init(data); + Curl_initinfo(data); - /* most recent connection is not yet defined */ - data->state.lastconnect = NULL; + /* most recent connection is not yet defined */ + data->state.lastconnect = NULL; - data->progress.flags |= PGRS_HIDE; - data->state.current_speed = -1; /* init to negative == impossible */ - data->set.fnmatch = ZERO_NULL; - data->set.maxconnects = DEFAULT_CONNCACHE_SIZE; /* for easy handles */ + data->progress.flags |= PGRS_HIDE; + data->state.current_speed = -1; /* init to negative == impossible */ + data->set.fnmatch = ZERO_NULL; + data->set.maxconnects = DEFAULT_CONNCACHE_SIZE; /* for easy handles */ - Curl_http2_init_state(&data->state); + Curl_http2_init_state(&data->state); + } } if(result) { |