mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Take care of fwrite() and fclose() return values. Patch by Alexey Tourbin.
This commit is contained in:
parent
6bdc34cfbc
commit
4b9ddf1481
@ -219,6 +219,7 @@ save_form_data_to_file(struct uri *uri)
|
||||
unsigned char *filename = get_tempdir_filename("elinks-XXXXXX");
|
||||
int fd;
|
||||
FILE *fp;
|
||||
size_t nmemb;
|
||||
|
||||
if (!filename) return NULL;
|
||||
|
||||
@ -230,6 +231,8 @@ save_form_data_to_file(struct uri *uri)
|
||||
|
||||
fp = fdopen(fd, "w");
|
||||
if (!fp) {
|
||||
|
||||
error:
|
||||
unlink(filename);
|
||||
mem_free(filename);
|
||||
close(fd);
|
||||
@ -241,9 +244,15 @@ save_form_data_to_file(struct uri *uri)
|
||||
unsigned char *formdata = strchr(uri->post, '\n');
|
||||
|
||||
formdata = formdata ? formdata + 1 : uri->post;
|
||||
fwrite(formdata, strlen(formdata), 1, fp);
|
||||
nmemb = fwrite(formdata, strlen(formdata), 1, fp);
|
||||
if (nmemb != 1) {
|
||||
fclose(fp);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
if (fclose(fp) != 0)
|
||||
goto error;
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user