[PATCH] src/elfclassify.c: Fix memory leak in check_ar_members
Mark Wielaard
mark@klomp.org
Tue Feb 10 13:48:18 GMT 2026
Hi Aaron,
On Mon, 2026-02-09 at 08:16 -0500, Aaron Merey wrote:
> If current_path needs to be reallocated, full_path is assigned a newly
> malloced buffer and then full_path is assigned to current_path. This
> leaks the previous value of full_path.
>
> Free full_path before reassigning it.
>
> Signed-off-by: Aaron Merey <amerey@redhat.com>
> ---
> src/elfclassify.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/src/elfclassify.c b/src/elfclassify.c
> index 307771b2..80a376a4 100644
> --- a/src/elfclassify.c
> +++ b/src/elfclassify.c
> @@ -866,6 +866,8 @@ check_ar_members (void)
> bad_ar = true;
> break;
> }
> +
> + free (full_path);
> full_path = new_path;
> }
>
Oops, my mistake when adding the --any-ar-member option.
This looks like the right way to fix this.
Thanks,
Mark
More information about the Elfutils-devel
mailing list