From 111e71c431bae9c69a7e1ed7e192fc58ad2e3c53 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 2 May 2020 15:18:35 +0200 Subject: [PATCH] test: fix potential use-after-free CID#1428676. --- src/test/test-cgroup-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c index 5826d6ec28..ea47f5affa 100644 --- a/src/test/test-cgroup-util.c +++ b/src/test/test-cgroup-util.c @@ -388,7 +388,7 @@ static void test_cg_get_keyed_attribute(void) { assert_se(val == NULL); assert_se(cg_get_keyed_attribute("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec"), &val) == 0); - free(val); + val = mfree(val); assert_se(cg_get_keyed_attribute_graceful("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec"), &val) == 1); log_info("cpu /init.scope cpu.stat [usage_usec] → \"%s\"", val);