aboutsummaryrefslogtreecommitdiff
path: root/src/tool_operate.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2011-10-05 15:06:26 +0200
committerYang Tse <yangsita@gmail.com>2011-10-05 15:06:26 +0200
commit5bf0d74120a92fb834b0d13098c0b5e93249a84f (patch)
tree3a89799eee7cc7f3d7e50b7598735b080444307f /src/tool_operate.c
parentfd87d9d2b9e8a5ebb8e49f0a5611e40289fa9f05 (diff)
curl tool: OOM handling fixes
Diffstat (limited to 'src/tool_operate.c')
-rw-r--r--src/tool_operate.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 9624f424a..d4671eb39 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -317,6 +317,11 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
/* Use the postfields data for a http get */
httpgetfields = strdup(config->postfields);
Curl_safefree(config->postfields);
+ if(!httpgetfields) {
+ helpf(config->errors, "out of memory\n");
+ res = CURLE_OUT_OF_MEMORY;
+ goto quit_curl;
+ }
if(SetHTTPrequest(config,
(config->no_body?HTTPREQ_HEAD:HTTPREQ_GET),
&config->httpreq)) {
@@ -515,7 +520,9 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
if(!outfile) {
/* extract the file name from the URL */
- outfile = get_url_file_name(this_url);
+ res = get_url_file_name(&outfile, this_url);
+ if(res)
+ goto show_error;
if((!outfile || !*outfile) && !config->content_disposition) {
helpf(config->errors, "Remote file name has no length!\n");
res = CURLE_WRITE_ERROR;