[PATCH 2/2] alfred: free the correct capability set when cap_init() fails
Sven Eckelmann <[email protected]> Wed, 29 Jul 2026 08:26:29 +0200
| Newsgroups | org.open-mesh.lists.batman |
|---|---|
| Message-ID | <[email protected]> |
reduce_capabilities() first allocates the current capability state with
cap_get_proc() into cap_cur and then allocates a fresh capability set
with cap_init() into cap_new. When the latter fails it tries to deallocate
the NULL cap_new.
Free cap_cur instead to avoid a leak.
Fixes: b0877b387ba1 ("alfred: Drop capabilities when not needed")
Signed-off-by: Sven Eckelmann <[email protected]>
---
main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/main.c b/main.c
index 9c38fd7..07e3cca 100644
--- a/main.c
+++ b/main.c
@@ -84,7 +84,7 @@ static int reduce_capabilities(void)
cap_new = cap_init();
if (!cap_new) {
perror("cap_init");
- cap_free(cap_new);
+ cap_free(cap_cur);
return -1;
}
--
2.47.3