From: John Baldwin <jhb@FreeBSD.org>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Remove alloca from osabi.c
Date: Mon, 14 Aug 2023 10:48:03 -0700 [thread overview]
Message-ID: <47f3c866-a469-5b77-c815-6309a136df65@FreeBSD.org> (raw)
In-Reply-To: <20230814164820.16355-1-tom@tromey.com>
On 8/14/23 9:48 AM, Tom Tromey wrote:
> I noticed that the call to alloca in osabi.c can be replaced with a
> statically-sized buffer, because some code just before the declaration
> ensures that the length is bounded.
> ---
> gdb/osabi.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/gdb/osabi.c b/gdb/osabi.c
> index d18802ac3a4..ad3dad5b849 100644
> --- a/gdb/osabi.c
> +++ b/gdb/osabi.c
> @@ -463,7 +463,6 @@ generic_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect,
> {
> const char *name;
> unsigned int sectsize;
> - char *note;
>
> name = bfd_section_name (sect);
> sectsize = bfd_section_size (sect);
> @@ -477,7 +476,7 @@ generic_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect,
> compressed section. But, since note sections are not compressed,
> deferring the reading until we recognize the section avoids any
> error. */
> - note = (char *) alloca (sectsize);
> + char note[MAX_NOTESZ];
>
> /* .note.ABI-tag notes, used by GNU/Linux and FreeBSD. */
> if (strcmp (name, ".note.ABI-tag") == 0)
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
--
John Baldwin
prev parent reply other threads:[~2023-08-14 17:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-14 16:48 Tom Tromey
2023-08-14 17:48 ` John Baldwin [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=47f3c866-a469-5b77-c815-6309a136df65@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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).