From cb233a73c6209dcd29dc476b288ccefa0e55031d Mon Sep 17 00:00:00 2001 From: shivanayak Date: Mon, 9 Mar 2026 22:16:00 +0530 Subject: [PATCH] daemon: fix memory leak in do_aug_match on realloc failure (#313) When realloc fails, vp is NULL so free(vp) is a no-op. The original matches array (and all r strings allocated by aug_match) is leaked. Use free_stringslen to properly free the array and its contents. Co-authored-by: Claude Opus 4.6 --- daemon/augeas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/augeas.c b/daemon/augeas.c index b34222ab5..b4c03e44e 100644 --- a/daemon/augeas.c +++ b/daemon/augeas.c @@ -342,7 +342,7 @@ do_aug_match (const char *path) vp = realloc (matches, sizeof (char *) * (r+1)); if (vp == NULL) { reply_with_perror ("realloc"); - free (vp); + free_stringslen (matches, r); return NULL; } matches = vp;