From 70e43ba8d4ee76ff43b51948f37f6db0bf3e2bb0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 7 Apr 2008 21:32:19 -0400 Subject: [PATCH] Detect failure to create download target file. --- main.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) 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); -- 1.7.1