[PATCH 4/7] test: self: ramfs: fix memory leak
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri May 17 00:48:21 PDT 2024
Like many other tests, ramfs also leaks memory. Fix this.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
test/self/ramfs.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/test/self/ramfs.c b/test/self/ramfs.c
index 1bc2b3b068f0..239e3e690740 100644
--- a/test/self/ramfs.c
+++ b/test/self/ramfs.c
@@ -58,7 +58,7 @@ static void test_ramfs(void)
char *content = NULL;
char *oldpwd = NULL;
DIR *dir = NULL;
- const char *dname;
+ char *dname;
struct stat st;
int i, j, ret, fd;
struct dirent *d;
@@ -196,6 +196,8 @@ static void test_ramfs(void)
expect_success(memcmp(buf, ARRAY_AND_SIZE(hello)),
"read_file() content");
}
+
+ free(buf);
}
out:
@@ -209,5 +211,6 @@ static void test_ramfs(void)
dir = opendir(dname);
expect_fail(dir ? 0 : -EISDIR, "opening removed directory");
+ free(dname);
}
bselftest(core, test_ramfs);
--
2.39.2
More information about the barebox
mailing list