tweaks: don't close a descriptor when its stream has already been closed
parent
807f5c2e69
commit
a5981ab043
10
src/files.c
10
src/files.c
|
@ -704,13 +704,11 @@ int is_file_writable(const char *filename)
|
||||||
if ((fd = open(full_filename, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR |
|
if ((fd = open(full_filename, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR |
|
||||||
S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1)
|
S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1)
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
else {
|
else if ((f = fdopen(fd, "a")) == NULL) {
|
||||||
if ((f = fdopen(fd, "a")) == NULL)
|
result = FALSE;
|
||||||
result = FALSE;
|
|
||||||
else
|
|
||||||
fclose(f);
|
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
} else
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
free(full_filename);
|
free(full_filename);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue