[binutils-gdb] PR28448, Memory leak in function add_symbols(plugin.c)
Alan Modra
amodra@sourceware.org
Thu Feb 15 08:45:27 GMT 2024
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=19bfbfa6659c7733d3148dcce5125a0eb3fd9670
commit 19bfbfa6659c7733d3148dcce5125a0eb3fd9670
Author: Alan Modra <amodra@gmail.com>
Date: Thu Feb 15 16:55:59 2024 +1030
PR28448, Memory leak in function add_symbols(plugin.c)
PR 28448
* plugin.c (add_symbols): bfd_alloc memory for symptrs. Check
bfd_make_empty_symbol return.
Diff:
---
ld/plugin.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
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;
More information about the Binutils-cvs
mailing list