]> granicus.if.org Git - curl/commitdiff
Fixed segmentation fault when Metalink has no valid file or no resource.
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
Mon, 14 May 2012 12:55:48 +0000 (21:55 +0900)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 26 May 2012 21:11:14 +0000 (23:11 +0200)
src/tool_metalink.c

index b442fc0d7596cf682feded3601a549ced6f886e0..d31502ab2d450e5a7a0c7f187caaa353f355e3dd 100644 (file)
@@ -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