public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PR28448, Memory leak in function add_symbols(plugin.c)
@ 2024-02-15  8:12 Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2024-02-15  8:12 UTC (permalink / raw)
  To: binutils

	PR 28448
	* plugin.c (add_symbols): bfd_alloc memory for symptrs.  Check
	bfd_make_empty_symbol return.

diff --git a/ld/plugin.c b/ld/plugin.c
index e982869072b..f81ab02b3a6 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -506,7 +506,9 @@ add_symbols (void *handle, int nsyms, const struct ld_plugin_symbol *syms)
   int n;
 
   ASSERT (called_plugin);
-  symptrs = xmalloc (nsyms * sizeof *symptrs);
+  symptrs = bfd_alloc (abfd, nsyms * sizeof *symptrs);
+  if (symptrs == NULL)
+    return LDPS_ERR;
   for (n = 0; n < nsyms; n++)
     {
       enum ld_plugin_status rv;
@@ -514,6 +516,8 @@ add_symbols (void *handle, int nsyms, const struct ld_plugin_symbol *syms)
 
       bfdsym = bfd_make_empty_symbol (abfd);
       symptrs[n] = bfdsym;
+      if (bfdsym == NULL)
+	return LDPS_ERR;
       rv = asymbol_from_plugin_symbol (abfd, bfdsym, syms + n);
       if (rv != LDPS_OK)
 	return rv;

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

* PR28448, Memory leak in function add_symbols(plugin.c)
@ 2024-02-15  8:44 Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2024-02-15  8:44 UTC (permalink / raw)
  To: binutils

	PR 28448
	* plugin.c (add_symbols): bfd_alloc memory for symptrs.  Check
	bfd_make_empty_symbol return.

diff --git a/ld/plugin.c b/ld/plugin.c
index e982869072b..f81ab02b3a6 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -506,7 +506,9 @@ add_symbols (void *handle, int nsyms, const struct ld_plugin_symbol *syms)
   int n;
 
   ASSERT (called_plugin);
-  symptrs = xmalloc (nsyms * sizeof *symptrs);
+  symptrs = bfd_alloc (abfd, nsyms * sizeof *symptrs);
+  if (symptrs == NULL)
+    return LDPS_ERR;
   for (n = 0; n < nsyms; n++)
     {
       enum ld_plugin_status rv;
@@ -514,6 +516,8 @@ add_symbols (void *handle, int nsyms, const struct ld_plugin_symbol *syms)
 
       bfdsym = bfd_make_empty_symbol (abfd);
       symptrs[n] = bfdsym;
+      if (bfdsym == NULL)
+	return LDPS_ERR;
       rv = asymbol_from_plugin_symbol (abfd, bfdsym, syms + n);
       if (rv != LDPS_OK)
 	return rv;

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-15  8:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-15  8:12 PR28448, Memory leak in function add_symbols(plugin.c) Alan Modra
2024-02-15  8:44 Alan Modra

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