mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
save_textarea_file(): cleanup handling of error, closing descriptors
and unlinking created file. Patch by Alexey Tourbin.
This commit is contained in:
parent
12ec62810b
commit
1e00f2d10d
@ -539,15 +539,22 @@ save_textarea_file(unsigned char *value)
|
||||
if (!filename) return NULL;
|
||||
|
||||
fd = safe_mkstemp(filename);
|
||||
if (fd >= 0) fp = fdopen(fd, "w");
|
||||
|
||||
if (fp) {
|
||||
fwrite(value, strlen(value), 1, fp);
|
||||
fclose(fp);
|
||||
} else {
|
||||
if (fd < 0) {
|
||||
mem_free(filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fp = fdopen(fd, "w");
|
||||
if (!fp) {
|
||||
unlink(filename);
|
||||
mem_free(filename);
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fwrite(value, strlen(value), 1, fp);
|
||||
fclose(fp);
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user