mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user