nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit a5981ab04308c9302df3c787cb654ee613f791ce
parent 807f5c2e69e14b87dc0800c9e39630780bd6a7cf
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed, 16 Aug 2017 20:31:38 +0200

tweaks: don't close a descriptor when its stream has already been closed

Diffstat:
Msrc/files.c | 10++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/files.c b/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 | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1) result = FALSE; - else { - if ((f = fdopen(fd, "a")) == NULL) - result = FALSE; - else - fclose(f); + else if ((f = fdopen(fd, "a")) == NULL) { + result = FALSE; close(fd); - } + } else + fclose(f); free(full_filename);