Detect failure to create download target file.
authorKristian H?gsberg <krh@jiraiya.boston.redhat.com>
Mon Apr 07 21:32:19 2008 -0400 (2008-04-07)
changeset 207b7d55f3fa183
parent 206 75d4b6a55593
child 208 7b460017c221
Detect failure to create download target file.
main.c
     1.1 --- a/main.c	Mon Apr 07 21:29:21 2008 -0400
     1.2 +++ b/main.c	Mon Apr 07 21:32:19 2008 -0400
     1.3 @@ -267,6 +267,11 @@
     1.4  
     1.5  	if (stat(file, &buf) < 0) {
     1.6  		fp = fopen(file, "w");
     1.7 +		if (fp == NULL) {
     1.8 +			fprintf(stderr,
     1.9 +				"failed to open %s for writing\n", file);
    1.10 +			return -1;
    1.11 +		}
    1.12  		curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
    1.13  		curl_easy_setopt(curl, CURLOPT_URL, url);
    1.14  		res = curl_easy_perform(curl);