aboutsummaryrefslogtreecommitdiff
path: root/binutils/objcopy.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-03-05 14:57:47 +1030
committerAlan Modra <amodra@gmail.com>2020-03-05 15:23:22 +1030
commitd1faf7ca0a9ecbc7f89998638e5cf08d3dca6e84 (patch)
tree49994208aae554d4c20ae642b067ea2306193d07 /binutils/objcopy.c
parentdee35d026c92b4054a90d655324dc90b4ea6cbfc (diff)
downloadgdb-d1faf7ca0a9ecbc7f89998638e5cf08d3dca6e84.zip
gdb-d1faf7ca0a9ecbc7f89998638e5cf08d3dca6e84.tar.gz
gdb-d1faf7ca0a9ecbc7f89998638e5cf08d3dca6e84.tar.bz2
PR25629, objcopy : SIGSEGV in filter_symbols
PR 25629 * objcopy.c (filter_symbols): Don't segfault on NULL prefix_symbols_string.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r--binutils/objcopy.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index daee570..3b9f1b7 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1580,9 +1580,14 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
if (add_leading_char || prefix_symbols_string)
{
char *n, *ptr;
+ size_t len = strlen (name) + 1;
- ptr = n = (char *) xmalloc (1 + strlen (prefix_symbols_string)
- + strlen (name) + 1);
+ if (add_leading_char)
+ len++;
+ if (prefix_symbols_string)
+ len += strlen (prefix_symbols_string);
+
+ ptr = n = (char *) xmalloc (len);
if (add_leading_char)
*ptr++ = bfd_get_symbol_leading_char (obfd);