public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] x86: Fix memory leaks in tc_gen_reloc
@ 2024-04-09 23:02 H.J. Lu
  0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2024-04-09 23:02 UTC (permalink / raw)
  To: binutils

Replace XNEW with bfd_xalloc to fix memory leaks in tc_gen_reloc.

	* config/tc-i386.c (tc_gen_reloc): Replace XNEW with bfd_xalloc.
---
 gas/config/tc-i386.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 502cc1b6978..122983ece79 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -17583,8 +17583,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
       code = BFD_RELOC_X86_64_GOTPC64;
     }
 
-  rel = XNEW (arelent);
-  rel->sym_ptr_ptr = XNEW (asymbol *);
+  rel = bfd_xalloc (stdoutput, sizeof (arelent));
+  rel->sym_ptr_ptr = bfd_xalloc (stdoutput, sizeof (asymbol *));
   *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
 
   rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
-- 
2.44.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-09 23:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-09 23:02 [PATCH] x86: Fix memory leaks in tc_gen_reloc H.J. Lu

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).