1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-29 01:45:34 +00:00

If there is nothing to write do not even open the file for write. Patch

by Alexey Tourbin.
This commit is contained in:
Laurent MONIN 2007-03-05 21:34:45 +01:00 committed by Laurent MONIN
parent 4b9ddf1481
commit edb8d9001c

View File

@ -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,16 +242,14 @@ error:
return NULL;
}
if (uri->post) {
/* Jump the content type */
unsigned char *formdata = strchr(uri->post, '\n');
/* Jump the content type */
formdata = strchr(uri->post, '\n');
formdata = formdata ? formdata + 1 : uri->post;
formdata = formdata ? formdata + 1 : uri->post;
nmemb = fwrite(formdata, strlen(formdata), 1, fp);
if (nmemb != 1) {
fclose(fp);
goto error;
}
nmemb = fwrite(formdata, strlen(formdata), 1, fp);
if (nmemb != 1) {
fclose(fp);
goto error;
}
if (fclose(fp) != 0)