diff options
Diffstat (limited to 'bfd/mach-o.c')
-rw-r--r-- | bfd/mach-o.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/bfd/mach-o.c b/bfd/mach-o.c index 166dd65..bde89b0 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -1,5 +1,5 @@ /* Mach-O support for BFD. - Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 + Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -1923,13 +1923,18 @@ bfd_mach_o_core_fetch_environment (bfd *abfd, if (size > (end - start)) size = (end - start); - buf = bfd_realloc (buf, size); - + buf = bfd_realloc_or_free (buf, size); + if (buf == NULL) + return -1; + bfd_seek (abfd, end - size, SEEK_SET); nread = bfd_bread (buf, size, abfd); if (nread != size) - return -1; + { + free (buf); + return -1; + } for (offset = 4; offset <= size; offset += 4) { @@ -1952,6 +1957,7 @@ bfd_mach_o_core_fetch_environment (bfd *abfd, *rlen = top - bottom; memcpy (*rbuf, buf + size - *rlen, *rlen); + free (buf); return 0; } } @@ -1961,6 +1967,8 @@ bfd_mach_o_core_fetch_environment (bfd *abfd, size *= 2; } + + free (buf); } } |