diff options
author | Alan Modra <amodra@gmail.com> | 2025-01-01 22:52:41 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2025-01-01 22:52:41 +1030 |
commit | 822bda23f618286724e449815c8da8cde03e32e0 (patch) | |
tree | bf95b625a1c9a202cc04f241726e5217576c9e1c | |
parent | 4739b9137e1fe1cfaf2e0de6924c122035942b26 (diff) | |
download | gdb-822bda23f618286724e449815c8da8cde03e32e0.zip gdb-822bda23f618286724e449815c8da8cde03e32e0.tar.gz gdb-822bda23f618286724e449815c8da8cde03e32e0.tar.bz2 |
gnu_debuglink related memory leak
* opncls.c (bfd_fill_in_gnu_debuglink_section): Free section
contents on success too.
-rw-r--r-- | bfd/opncls.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/bfd/opncls.c b/bfd/opncls.c index fb0bca7..a0b30f5 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -1768,7 +1768,7 @@ bfd_fill_in_gnu_debuglink_section (bfd *abfd, debuglink_size &= ~3; debuglink_size += 4; - contents = (char *) bfd_malloc (debuglink_size); + contents = bfd_malloc (debuglink_size); if (contents == NULL) { /* XXX Should we delete the section from the bfd ? */ @@ -1781,14 +1781,9 @@ bfd_fill_in_gnu_debuglink_section (bfd *abfd, bfd_put_32 (abfd, crc32, contents + crc_offset); - if (! bfd_set_section_contents (abfd, sect, contents, 0, debuglink_size)) - { - /* XXX Should we delete the section from the bfd ? */ - free (contents); - return false; - } - - return true; + bool ret = bfd_set_section_contents (abfd, sect, contents, 0, debuglink_size); + free (contents); + return ret; } /* Finds the build-id associated with @var{abfd}. If the build-id is |