mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
save_textarea_file(): do not open file for writing if not needed. Patch
by Alexey Tourbin.
This commit is contained in:
parent
ecce8bfa91
commit
86686983c0
@ -534,7 +534,7 @@ save_textarea_file(unsigned char *value)
|
||||
unsigned char *filename;
|
||||
FILE *fp = NULL;
|
||||
int fd;
|
||||
size_t nmemb;
|
||||
size_t nmemb, len;
|
||||
|
||||
filename = get_tempdir_filename("elinks-area-XXXXXX");
|
||||
if (!filename) return NULL;
|
||||
@ -545,6 +545,9 @@ save_textarea_file(unsigned char *value)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = strlen(value);
|
||||
if (len == 0) return filename;
|
||||
|
||||
fp = fdopen(fd, "w");
|
||||
if (!fp) {
|
||||
|
||||
@ -555,7 +558,7 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nmemb = fwrite(value, strlen(value), 1, fp);
|
||||
nmemb = fwrite(value, len, 1, fp);
|
||||
if (nmemb != 1) {
|
||||
fclose(fp);
|
||||
goto error;
|
||||
|
Loading…
Reference in New Issue
Block a user