mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
If there is nothing to write do not even open the file for write. Patch
by Alexey Tourbin.
This commit is contained in:
parent
4b9ddf1481
commit
edb8d9001c
@ -220,6 +220,7 @@ save_form_data_to_file(struct uri *uri)
|
||||
int fd;
|
||||
FILE *fp;
|
||||
size_t nmemb;
|
||||
unsigned char *formdata;
|
||||
|
||||
if (!filename) return NULL;
|
||||
|
||||
@ -229,6 +230,8 @@ save_form_data_to_file(struct uri *uri)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!uri->post) return filename;
|
||||
|
||||
fp = fdopen(fd, "w");
|
||||
if (!fp) {
|
||||
|
||||
@ -239,17 +242,15 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (uri->post) {
|
||||
/* Jump the content type */
|
||||
unsigned char *formdata = strchr(uri->post, '\n');
|
||||
|
||||
formdata = strchr(uri->post, '\n');
|
||||
formdata = formdata ? formdata + 1 : uri->post;
|
||||
|
||||
nmemb = fwrite(formdata, strlen(formdata), 1, fp);
|
||||
if (nmemb != 1) {
|
||||
fclose(fp);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (fclose(fp) != 0)
|
||||
goto error;
|
||||
|
Loading…
Reference in New Issue
Block a user