]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2009-10-22 Paul Pluzhnikov <ppluzhnikov@google.com>
authorPaul Pluzhnikov <ppluzhnikov@google.com>
Thu, 22 Oct 2009 20:31:36 +0000 (20:31 +0000)
committerPaul Pluzhnikov <ppluzhnikov@google.com>
Thu, 22 Oct 2009 20:31:36 +0000 (20:31 +0000)
PR gdb/10819
* dwarf2-frame.c (find_cie): Don't call bsearch on empty cie_table.
* objfiles.c (find_pc_section): Likewise.
(update_section_map): Don't allocate empty table.

gdb/ChangeLog
gdb/dwarf2-frame.c
gdb/objfiles.c

index bb5afad0d8f522c944b33edef3a0fd1626a18ec1..d15b284f6791a9f35edd7aa8b2cd6996654dbd76 100644 (file)
@@ -1,3 +1,10 @@
+2009-10-22  Paul Pluzhnikov  <ppluzhnikov@google.com>
+
+       PR gdb/10819
+       * dwarf2-frame.c (find_cie): Don't call bsearch on empty cie_table.
+       * objfiles.c (find_pc_section): Likewise.
+       (update_section_map): Don't allocate empty table.
+       
 2009-10-19  Don Lee  <don.lee@sunplusct.com>
 
        * score-tdep.c: Delete some simulator dependent codes.
index 668c4344bd428377c452439334d9c9290d6c08e9..201b5207a362c5c76b63268bc3731f594281e633 100644 (file)
@@ -1525,6 +1525,14 @@ find_cie (struct dwarf2_cie_table *cie_table, ULONGEST cie_pointer)
 {
   struct dwarf2_cie **p_cie;
 
+  /* The C standard (ISO/IEC 9899:TC2) requires the BASE argument to
+     bsearch be non-NULL.  */
+  if (cie_table->entries == NULL)
+    {
+      gdb_assert (cie_table->num_entries == 0);
+      return NULL;
+    }
+
   p_cie = bsearch (&cie_pointer, cie_table->entries, cie_table->num_entries,
                    sizeof (cie_table->entries[0]), bsearch_cie_cmp);
   if (p_cie != NULL)
index 8dcca702a76f5b742649afb644104c8a06e1656c..60904a2ab30684f9b5051cd8723a6e099d48c188 100644 (file)
@@ -1045,6 +1045,14 @@ update_section_map (struct obj_section ***pmap, int *pmap_size)
     if (insert_section_p (objfile->obfd, s->the_bfd_section))
       alloc_size += 1;
 
+  /* This happens on detach/attach (e.g. in gdb.base/attach.exp).  */
+  if (alloc_size == 0)
+    {
+      *pmap = NULL;
+      *pmap_size = 0;
+      return;
+    }
+
   map = xmalloc (alloc_size * sizeof (*map));
 
   i = 0;
@@ -1105,6 +1113,14 @@ find_pc_section (CORE_ADDR pc)
       objfiles_changed_p = 0;
     }
 
+  /* The C standard (ISO/IEC 9899:TC2) requires the BASE argument to
+     bsearch be non-NULL.  */
+  if (sections == NULL)
+    {
+      gdb_assert (num_sections == 0);
+      return NULL;
+    }
+
   sp = (struct obj_section **) bsearch (&pc, sections, num_sections,
                                        sizeof (*sections), bsearch_cmp);
   if (sp != NULL)