Detect failure to create download target file.
authorKristian Høgsberg <krh@jiraiya.boston.redhat.com>
Tue, 8 Apr 2008 01:32:19 +0000 (21:32 -0400)
committerKristian Høgsberg <krh@jiraiya.boston.redhat.com>
Tue, 8 Apr 2008 01:32:19 +0000 (21:32 -0400)
main.c

diff --git a/main.c b/main.c
index cb817b1..a72d419 100644 (file)
--- a/main.c
+++ b/main.c
@@ -267,6 +267,11 @@ download_if_missing(const char *url, const char *file)
 
        if (stat(file, &buf) < 0) {
                fp = fopen(file, "w");
+               if (fp == NULL) {
+                       fprintf(stderr,
+                               "failed to open %s for writing\n", file);
+                       return -1;
+               }
                curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
                curl_easy_setopt(curl, CURLOPT_URL, url);
                res = curl_easy_perform(curl);