# HG changeset patch # User Kristian H?gsberg # Date 1207618339 14400 # Node ID b7d55f3fa1835fdcbee885d78a0a425bf0ff9904 # Parent 75d4b6a555931cc7ee95bfd887c6e9495de6d083 Detect failure to create download target file. diff -r 75d4b6a55593 -r b7d55f3fa183 main.c --- a/main.c Mon Apr 07 21:29:21 2008 -0400 +++ b/main.c Mon Apr 07 21:32:19 2008 -0400 @@ -267,6 +267,11 @@ 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);