This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] ld/main.c: Return after einfo() in warning_find_reloc().


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]