mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -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");
|
unsigned char *filename = get_tempdir_filename("elinks-XXXXXX");
|
||||||
int fd;
|
int fd;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
size_t nmemb;
|
||||||
|
|
||||||
if (!filename) return NULL;
|
if (!filename) return NULL;
|
||||||
|
|
||||||
@ -230,6 +231,8 @@ save_form_data_to_file(struct uri *uri)
|
|||||||
|
|
||||||
fp = fdopen(fd, "w");
|
fp = fdopen(fd, "w");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
|
|
||||||
|
error:
|
||||||
unlink(filename);
|
unlink(filename);
|
||||||
mem_free(filename);
|
mem_free(filename);
|
||||||
close(fd);
|
close(fd);
|
||||||
@ -241,9 +244,15 @@ save_form_data_to_file(struct uri *uri)
|
|||||||
unsigned char *formdata = strchr(uri->post, '\n');
|
unsigned char *formdata = strchr(uri->post, '\n');
|
||||||
|
|
||||||
formdata = formdata ? formdata + 1 : uri->post;
|
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;
|
return filename;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user