1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

save_textarea_file(): handle return values of fwrite() and fclose(). Patch

by Alexey Tourbin.
This commit is contained in:
Laurent MONIN 2007-03-05 21:47:09 +01:00 committed by Laurent MONIN
parent 1e00f2d10d
commit ecce8bfa91

View File

@ -534,6 +534,7 @@ save_textarea_file(unsigned char *value)
unsigned char *filename;
FILE *fp = NULL;
int fd;
size_t nmemb;
filename = get_tempdir_filename("elinks-area-XXXXXX");
if (!filename) return NULL;
@ -546,14 +547,22 @@ save_textarea_file(unsigned char *value)
fp = fdopen(fd, "w");
if (!fp) {
error:
unlink(filename);
mem_free(filename);
close(fd);
return NULL;
}
fwrite(value, strlen(value), 1, fp);
nmemb = fwrite(value, strlen(value), 1, fp);
if (nmemb != 1) {
fclose(fp);
goto error;
}
if (fclose(fp) != 0)
goto error;
return filename;
}