From: Kristian Høgsberg Date: Tue, 8 Apr 2008 01:32:19 +0000 (-0400) Subject: Detect failure to create download target file. X-Git-Tag: 0.1~157 X-Git-Url: http://project.juiblex.co.uk/git/?a=commitdiff_plain;h=70e43ba8d4ee76ff43b51948f37f6db0bf3e2bb0;p=razor.git Detect failure to create download target file. --- diff --git a/main.c b/main.c index cb817b1..a72d419 100644 --- 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);