From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH] Remove alloca from osabi.c
Date: Mon, 14 Aug 2023 10:48:20 -0600 [thread overview]
Message-ID: <20230814164820.16355-1-tom@tromey.com> (raw)
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)
--
2.41.0
next reply other threads:[~2023-08-14 16:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-14 16:48 Tom Tromey [this message]
2023-08-14 17:48 ` John Baldwin
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=20230814164820.16355-1-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/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).