aboutsummaryrefslogtreecommitdiff
path: root/bfd/bfd.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2007-06-29 14:36:21 +0000
committerNick Clifton <nickc@redhat.com>2007-06-29 14:36:21 +0000
commit32e8a950c4e551038786bc4980dcb9fbfb8384b0 (patch)
tree38c7ee8e71cf992989bc122da371de74e94c0334 /bfd/bfd.c
parent3d3d428f048cd724b634cb0252dd187f3fabc627 (diff)
downloadgdb-32e8a950c4e551038786bc4980dcb9fbfb8384b0.zip
gdb-32e8a950c4e551038786bc4980dcb9fbfb8384b0.tar.gz
gdb-32e8a950c4e551038786bc4980dcb9fbfb8384b0.tar.bz2
* bfd.c (bfd_demangle): Plug memory leak (Coverity).
Diffstat (limited to 'bfd/bfd.c')
-rw-r--r--bfd/bfd.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/bfd/bfd.c b/bfd/bfd.c
index b1c49aa..510df0a 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1773,12 +1773,12 @@ bfd_demangle (bfd *abfd, const char *name, int options)
suf = res + len;
suf_len = strlen (suf) + 1;
final = bfd_malloc (pre_len + len + suf_len);
- if (final == NULL)
- return NULL;
-
- memcpy (final, pre, pre_len);
- memcpy (final + pre_len, res, len);
- memcpy (final + pre_len + len, suf, suf_len);
+ if (final != NULL)
+ {
+ memcpy (final, pre, pre_len);
+ memcpy (final + pre_len, res, len);
+ memcpy (final + pre_len + len, suf, suf_len);
+ }
free (res);
res = final;
}