diff options
author | Alan Modra <amodra@gmail.com> | 2025-01-17 10:50:51 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2025-01-17 19:06:39 +1030 |
commit | 0e4207c529e605fe4a17fe71b49ffb42576d0b83 (patch) | |
tree | 519725427198a3ecdeb5da0fa3f4a2646e741a00 | |
parent | e2b02acd77a38f372a17e2f039a04afaecffc212 (diff) | |
download | binutils-0e4207c529e605fe4a17fe71b49ffb42576d0b83.zip binutils-0e4207c529e605fe4a17fe71b49ffb42576d0b83.tar.gz binutils-0e4207c529e605fe4a17fe71b49ffb42576d0b83.tar.bz2 |
cmdline_add_object_only_section leak
Free ofilename on error path. Don't bother testing "if (foo)" before
"free (foo)".
-rw-r--r-- | ld/ldlang.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c index 2e82eef..74c0271 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -10778,8 +10778,7 @@ cmdline_add_object_only_section (bfd_byte *contents, size_t size) /* Must be freed after bfd_close (). */ free (isympp); - if (osympp) - free (osympp); + free (osympp); if (rename (ofilename, output_filename)) { @@ -10791,14 +10790,15 @@ cmdline_add_object_only_section (bfd_byte *contents, size_t size) return; loser: - if (isympp) - free (isympp); - if (osympp) - free (osympp); + free (isympp); + free (osympp); if (obfd) bfd_close (obfd); if (ofilename) - unlink (ofilename); + { + unlink (ofilename); + free (ofilename); + } einfo (_("%P%F: failed to add object-only section: %s\n"), err); } |