This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] ld/main.c: Return after einfo() in warning_find_reloc().
- From: Chen Gang <xili_gchen_5257 at hotmail dot com>
- To: binutils at sourceware dot org
- Cc: Chen Gang <gang dot chen dot 5i5j at gmail dot com>
- Date: Mon, 16 Mar 2015 14:03:27 +0800
- Subject: [PATCH] ld/main.c: Return after einfo() in warning_find_reloc().
- Authentication-results: sourceware.org; auth=none
einfo() is only for printing information, so if 'relsize' and 'relcount'
fail, they needs to return explicitly after einfo().
2015-03-16 Chen Gang <gang.chen.5i5j@gmail.com>
* ldmain.c (warning_find_reloc): Return after einfo().
---
ld/ChangeLog | 4 ++++
ld/ldmain.c | 11 +++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 0f8fbc4..9763a0c 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-16 Chen Gang <gang.chen.5i5j@gmail.com>
+
+ * ldmain.c (warning_find_reloc): Return after einfo().
+
2015-03-02 Alan Modra <amodra@gmail.com>
* ld.texinfo (Options <-z nocopyreloc>): Rewrite.
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 4b41288..f0071de 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -1224,14 +1224,21 @@ warning_find_reloc (bfd *abfd, asection *sec, void *iarg)
relsize = bfd_get_reloc_upper_bound (abfd, sec);
if (relsize < 0)
- einfo (_("%B%F: could not read relocs: %E\n"), abfd);
+ {
+ einfo (_("%B%F: could not read relocs: %E\n"), abfd);
+ return;
+ }
if (relsize == 0)
return;
relpp = (arelent **) xmalloc (relsize);
relcount = bfd_canonicalize_reloc (abfd, sec, relpp, info->asymbols);
if (relcount < 0)
- einfo (_("%B%F: could not read relocs: %E\n"), abfd);
+ {
+ einfo (_("%B%F: could not read relocs: %E\n"), abfd);
+ free (relpp);
+ return;
+ }
p = relpp;
pend = p + relcount;
--
1.9.3