diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2014-09-11 17:37:30 +0200 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2014-09-11 17:39:17 +0200 |
commit | 3f2e132a197ba3f5172cbbcd285e9aab021de8fc (patch) | |
tree | 43ccceee995cac2fa44ff97fc462f9941493cd6c /src | |
parent | 2b347169b9046ff2d735ef23e62a8c74f5151600 (diff) |
test: fix mem-leak in fdopen() test
We must free FILE* after function return to not leak resources. Note that
this also closes our fd as fdopen() takes ownership of it.
Reported by Philippe De Swert (via coverity).
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test-util.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c index 72a8a6b130..80425ca61a 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -918,11 +918,11 @@ static void test_readlink_and_make_absolute(void) { } static void test_read_one_char(void) { + _cleanup_fclose_ FILE *file = NULL; char r; bool need_nl; char name[] = "/tmp/test-read_one_char.XXXXXX"; - _cleanup_close_ int fd = -1; - FILE *file; + int fd; fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC); assert_se(fd >= 0); |