CgroupGetCgroup1 tripped LeakSanitizer because the test freed the
top-level struct cgroup with free(), leaving the controllers and control
values allocated by cgroup_get_cgroup() on the heap:
Direct leak of 4240 byte(s) in 5 object(s) allocated from:
#0 0x... in calloc
#1 cgroup_add_controller (<source>/libcgroup/src/wrapper.c:79)
#2 cgroup_get_cgroup (<source>/libcgroup/src/api.c:3973)
Replacing both free(cgrp) calls with cgroup_free(&cgrp) mirrors the
expected teardown path, unwinds the nested allocations, and clears
the ASan report without changing the test assertions.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
ASSERT_EQ(cgrp_vec, test_vec);
if (cgrp)
- free(cgrp);
+ cgroup_free(&cgrp);
}
/*
ASSERT_EQ(ret, ECGOTHER);
if (cgrp)
- free(cgrp);
+ cgroup_free(&cgrp);
}