[PATCH v1 4/7] bfd: fix memory leak when default-initializing an OAv2 attribute
Jan Beulich
jbeulich@suse.com
Thu Feb 5 10:52:46 GMT 2026
More information about the Binutils mailing list
Thu Feb 5 10:52:46 GMT 2026
- Previous message (by thread): [PATCH v1 4/7] bfd: fix memory leak when default-initializing an OAv2 attribute
- Next message (by thread): [PATCH v1 4/7] bfd: fix memory leak when default-initializing an OAv2 attribute
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 03.02.2026 11:00, Matthieu Longo wrote:
> --- a/bfd/elf-attrs.c
> +++ b/bfd/elf-attrs.c
> @@ -1078,7 +1078,10 @@ oav2_attr_overwrite_with_default (const struct bfd_link_info *info,
> if (subsec->encoding == OA_ENC_ULEB128)
> attr->val.uint = 0;
> else
> - attr->val.string = NULL;
> + {
> + free ((char *) attr->val.string);
> + attr->val.string = NULL;
> + }
> return;
> }
This is okay as is, yet I'd still like to ask: Much like you centralized things
in patch 3, how about doing so here as well? Possibly even the function introduced
there could be re-used here, maybe with the "merge" in its name dropped.
> @@ -1089,7 +1092,7 @@ oav2_attr_overwrite_with_default (const struct bfd_link_info *info,
> {
> if (attr->val.string != NULL)
> {
> - free ((void *) attr->val.string);
> + free ((char *) attr->val.string);
> attr->val.string = NULL;
> }
Why this change? void * _is_ the type free() takes. If you want both sides to be
consistent, I'd rather see you use void * in the earlier hunk as well.
Jan
- Previous message (by thread): [PATCH v1 4/7] bfd: fix memory leak when default-initializing an OAv2 attribute
- Next message (by thread): [PATCH v1 4/7] bfd: fix memory leak when default-initializing an OAv2 attribute
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list