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

Message ID 1519727138-3039-1-git-send-email-roirand@adacore.com
State New
Headers show
Series
  • [RFA] machoread.c: avoid a crash on OSO without symbols.
Related show

Commit Message

Xavier Roirand Feb. 27, 2018, 10:25 a.m.
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(+)

-- 
2.7.4

Patch

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)