From: Alan Modra <amodra@gmail.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: binutils@sourceware.org
Subject: Re: Fix small objcopy memory leak
Date: Mon, 31 Oct 2022 20:48:04 +1030 [thread overview]
Message-ID: <Y1+g3F4fFhkFw1Wc@squeak.grove.modra.org> (raw)
In-Reply-To: <21691094-d184-2eef-8bcc-7eb6d355d7e8@msgid.tls.msk.ru>
On Mon, Oct 31, 2022 at 12:24:21PM +0300, Michael Tokarev wrote:
> 29.10.2022 07:52, Alan Modra via Binutils wrote:
> > * objcopy.c (copy_archive): Free l->name.
> >
> > diff --git a/binutils/objcopy.c b/binutils/objcopy.c
> > index d20aaef9f4f..03350babb69 100644
> > --- a/binutils/objcopy.c
> > +++ b/binutils/objcopy.c
> > @@ -3744,6 +3744,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
> > bfd_close (l->obfd);
> > unlink (l->name);
> > }
> > + free ((char *) l->name);
>
> btw, why you cast it to char* ?
To explicitly remove the const qualifier. Otherwise we hit a
-Wdiscarded-qualifiers warning when l->name, a const char*, is
implicitly cast to void* by the free() prototype.
--
Alan Modra
Australia Development Lab, IBM
prev parent reply other threads:[~2022-10-31 10:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-29 4:52 Alan Modra
2022-10-31 9:24 ` Michael Tokarev
2022-10-31 10:18 ` Alan Modra [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y1+g3F4fFhkFw1Wc@squeak.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=mjt@tls.msk.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).