From: Nick Clifton Date: Fri, 29 Jun 2007 14:36:21 +0000 (+0000) Subject: * bfd.c (bfd_demangle): Plug memory leak (Coverity). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=32e8a950c4e551038786bc4980dcb9fbfb8384b0;p=binutils-gdb.git * bfd.c (bfd_demangle): Plug memory leak (Coverity). --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 33313c031ad..ad71032f6fa 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,7 @@ +2007-06-29 Michael Snyder + + * bfd.c (bfd_demangle): Plug memory leak (Coverity). + 2007-06-29 M R Swami Reddy * Makefile.am: Add cr16 related entry diff --git a/bfd/bfd.c b/bfd/bfd.c index b1c49aa08f4..510df0ab27f 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; }