aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-05-14 21:55:48 +0900
committerDaniel Stenberg <daniel@haxx.se>2012-05-26 23:11:14 +0200
commit94eb1328969b796e4ecce3a113fc6ba24c167254 (patch)
tree64402e2f2a391ceb7dc6c5174e6ff5e36fed763e
parent383641d70a01da00f2a2484e8e8c3f6f20d24adb (diff)
Fixed segmentation fault when Metalink has no valid file or no resource.
-rw-r--r--src/tool_metalink.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/tool_metalink.c b/src/tool_metalink.c
index b442fc0d7..d31502ab2 100644
--- a/src/tool_metalink.c
+++ b/src/tool_metalink.c
@@ -94,6 +94,10 @@ int parse_metalink(struct Configurable *config, const char *infile)
if(r != 0) {
return -1;
}
+ if(metalink->files == NULL) {
+ fprintf(config->errors, "\nMetalink does not contain any file.\n");
+ return 0;
+ }
ml = new_metalink(metalink);
if(config->metalink_list) {
@@ -107,7 +111,11 @@ int parse_metalink(struct Configurable *config, const char *infile)
for(files = metalink->files; *files; ++files) {
struct getout *url;
/* Skip an entry which has no resource. */
- if(!(*files)->resources[0]) continue;
+ if(!(*files)->resources) {
+ fprintf(config->errors, "\nFile %s does not have any resource.\n",
+ (*files)->name);
+ continue;
+ }
if(config->url_get ||
((config->url_get = config->url_list) != NULL)) {
/* there's a node here, if it already is filled-in continue to