From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: PowerPC md_end: Don't htab_delete(NULL)
Date: Tue, 12 Jul 2022 12:04:43 +0930 [thread overview]
Message-ID: <Yszdw1newun936yT@squeak.grove.modra.org> (raw)
It might be possible to hit md_end before md_begin is called, don't
segfault if so. Also, remove a useless check in insn_calloc.
* gas/config/tc-ppc.c (insn_calloc): Remove needless overflow
check.
(ppc_md_end): Check ppc_hash before deleting. Clear ppc_hash.
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index ac61cd8f122..5015777d600 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -1620,14 +1620,8 @@ insn_validate (const struct powerpc_opcode *op)
static void *
insn_calloc (size_t n, size_t size)
{
- size_t amt;
- void *ret;
- if (gas_mul_overflow (n, size, &amt))
- {
- obstack_alloc_failed_handler ();
- abort ();
- }
- ret = obstack_alloc (&insn_obstack, amt);
+ size_t amt = n * size;
+ void *ret = obstack_alloc (&insn_obstack, amt);
memset (ret, 0, amt);
return ret;
}
@@ -1903,8 +1897,12 @@ md_begin (void)
void
ppc_md_end (void)
{
- htab_delete (ppc_hash);
- _obstack_free (&insn_obstack, NULL);
+ if (ppc_hash)
+ {
+ htab_delete (ppc_hash);
+ _obstack_free (&insn_obstack, NULL);
+ }
+ ppc_hash = NULL;
}
void
--
Alan Modra
Australia Development Lab, IBM
reply other threads:[~2022-07-12 2:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=Yszdw1newun936yT@squeak.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@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).