diff options
author | Yang Tse <yangsita@gmail.com> | 2011-10-05 22:01:42 +0200 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2011-10-05 22:01:42 +0200 |
commit | 7296b2aa256049bec7ea7a372dee5cb319c7feca (patch) | |
tree | 5d64e31d6b369b774a85d2d4801af57f0d2b41c1 /src/tool_operate.c | |
parent | 6c849321d7545bcba1eb014d53b55db561015e52 (diff) |
curl tool: OOM handling fixes
Diffstat (limited to 'src/tool_operate.c')
-rw-r--r-- | src/tool_operate.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c index b7da80a71..9a06098a0 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -441,10 +441,18 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[]) if(!up && !infiles) Curl_nop_stmt; else { - if(inglob) - uploadfile = glob_next_url(inglob); - else if(!up) + if(inglob) { + res = glob_next_url(&uploadfile, inglob); + if(res == CURLE_OUT_OF_MEMORY) + helpf(config->errors, "out of memory\n"); + } + else if(!up) { uploadfile = strdup(infiles); + if(!uploadfile) { + helpf(config->errors, "out of memory\n"); + res = CURLE_OUT_OF_MEMORY; + } + } else uploadfile = NULL; if(!uploadfile) @@ -492,10 +500,17 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[]) outs.stream = stdout; outs.config = config; - if(urls) - this_url = glob_next_url(urls); + if(urls) { + res = glob_next_url(&this_url, urls); + if(res) + goto show_error; + } else if(!i) { this_url = strdup(urlnode->url); + if(!this_url) { + res = CURLE_OUT_OF_MEMORY; + goto show_error; + } } else this_url = NULL; @@ -541,12 +556,11 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[]) else if(urls) { /* fill '#1' ... '#9' terms from URL pattern */ char *storefile = outfile; - outfile = glob_match_url(storefile, urls); + res = glob_match_url(&outfile, storefile, urls); Curl_safefree(storefile); - if(!outfile) { + if(res) { /* bad globbing */ warnf(config, "bad output glob!\n"); - res = CURLE_FAILED_INIT; goto quit_urls; } } |