|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From 3f2e132a197ba3f5172cbbcd285e9aab021de8fc Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: David Herrmann <dh.herrmann@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Thu, 11 Sep 2014 17:37:30 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] test: fix mem-leak in fdopen() test
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
We must free FILE* after function return to not leak resources. Note that
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
this also closes our fd as fdopen() takes ownership of it.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Reported by Philippe De Swert (via coverity).
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/test/test-util.c | 4 ++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/test/test-util.c b/src/test/test-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 72a8a6b130..80425ca61a 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/test/test-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/test/test-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -918,11 +918,11 @@ static void test_readlink_and_make_absolute(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static void test_read_one_char(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ _cleanup_fclose_ FILE *file = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
char r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
bool need_nl;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
char name[] = "/tmp/test-read_one_char.XXXXXX";
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- _cleanup_close_ int fd = -1;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- FILE *file;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ int fd;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(fd >= 0);
|