From 9b604f9ce034ca487bb49272e119fc79edf479c8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 15 Nov 2024 14:28:23 -0500 Subject: Avoid potential open file leak in test --- test/test_filesystem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test') 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; -- cgit v1.2.1