summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-11-15 14:28:23 -0500
committerDavid Robillard <d@drobilla.net>2024-11-15 14:28:23 -0500
commit9b604f9ce034ca487bb49272e119fc79edf479c8 (patch)
tree5c2ba86cf2c10c4390d382ade43aecbf24d9d315 /test
parente58b18dbcea3646ac9ec8b0d96f54c1111819d59 (diff)
downloadzix-9b604f9ce034ca487bb49272e119fc79edf479c8.tar.gz
zix-9b604f9ce034ca487bb49272e119fc79edf479c8.tar.bz2
zix-9b604f9ce034ca487bb49272e119fc79edf479c8.zip
Avoid potential open file leak in test
Diffstat (limited to 'test')
-rw-r--r--test/test_filesystem.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/test/test_filesystem.c b/test/test_filesystem.c
index 9fd6007..511c66e 100644
--- a/test/test_filesystem.c
+++ b/test/test_filesystem.c
@@ -244,7 +244,8 @@ write_to_path(const char* const path, const char* const contents)
const size_t len = strlen(contents);
fwrite(contents, 1, len, f);
- ret = fflush(f) ? errno : ferror(f) ? EBADF : fclose(f) ? errno : 0;
+ ret = fflush(f) ? errno : ferror(f) ? EBADF : 0;
+ ret = (fclose(f) && !ret) ? errno : ret;
}
return ret;