aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2024-02-15 16:55:59 +1030
committerAlan Modra <amodra@gmail.com>2024-02-15 19:11:42 +1030
commit19bfbfa6659c7733d3148dcce5125a0eb3fd9670 (patch)
tree9581ea5a2fb198e7c2afe4f53f13c9c424ff96f6 /ld
parent313f04b6edcd09e0e7ff224bd54a892ab8f029aa (diff)
downloadgdb-19bfbfa6659c7733d3148dcce5125a0eb3fd9670.zip
gdb-19bfbfa6659c7733d3148dcce5125a0eb3fd9670.tar.gz
gdb-19bfbfa6659c7733d3148dcce5125a0eb3fd9670.tar.bz2
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.
Diffstat (limited to 'ld')
-rw-r--r--ld/plugin.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ld/plugin.c b/ld/plugin.c
index e982869..f81ab02 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;