This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

[RFA] machoread.c: avoid a crash on OSO without symbols.


gdb/ChangeLog (Tristan Gingold <gingold@adacore.com>)

	* machoread.c (macho_add_oso_symfile): Handle weird case
	of OSO without symbols.
---
 gdb/ChangeLog   | 6 ++++++
 gdb/machoread.c | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b9a9bcd..83b5073 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-27  Tristan Gingold  <gingold@adacore.com>
+
+	Pushed by Xavier Roirand <roirand@adacore.com>
+	* machoread.c (macho_add_oso_symfile): Handle weird case
+	of OSO without symbols.
+
 2018-02-26  Maciej W. Rozycki  <macro@mips.com>
 
 	* mips-tdep.c (mips_gdbarch_init): Don't use a 32-bit BFD
diff --git a/gdb/machoread.c b/gdb/machoread.c
index b270675..b00ef13 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -579,6 +579,11 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd,
                 {
                   struct macho_sym_hash_entry *ent;
 
+		  /* Nothing to do if there is no symbol (and avoid a crash
+		     while creating an empty hash table).  */
+		  if (oso->nbr_syms == 0)
+		    continue;
+
                   ent = (struct macho_sym_hash_entry *)
                     bfd_hash_lookup (&table, sym->name, FALSE, FALSE);
                   if (ent != NULL)
-- 
2.7.4


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