aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-08-26 20:25:04 +0930
committerAlan Modra <amodra@gmail.com>2020-08-26 23:23:45 +0930
commit4d43072582c3ccbb86485d79107a9d3550a1557a (patch)
tree83fb21c0a6f3d1f3784aa8090258b026306efff5
parent252e57fdd41118855f67ada7785b4ce3d5e61ad3 (diff)
downloadgdb-4d43072582c3ccbb86485d79107a9d3550a1557a.zip
gdb-4d43072582c3ccbb86485d79107a9d3550a1557a.tar.gz
gdb-4d43072582c3ccbb86485d79107a9d3550a1557a.tar.bz2
PR26507 UBSAN: elf32-xtensa.c:6013 null pointer bsearch
PR 26507 * elf32-xtensa.c (find_removed_literal): Don't bsearch empty map.
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/elf32-xtensa.c15
2 files changed, 14 insertions, 6 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 765188d..988e2f0 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,10 @@
2020-08-26 Alan Modra <amodra@gmail.com>
+ PR 26507
+ * elf32-xtensa.c (find_removed_literal): Don't bsearch empty map.
+
+2020-08-26 Alan Modra <amodra@gmail.com>
+
PR 26506
* elf32-xtensa.c (elf_xtensa_combine_prop_entries): Return early
when section is empty.
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 5184fbf..5824c59 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -6014,13 +6014,16 @@ find_removed_literal (removed_literal_list *removed_list, bfd_vma addr)
if (removed_list->map == NULL)
map_removed_literal (removed_list);
- p = bsearch (&addr, removed_list->map, removed_list->n_map,
- sizeof (*removed_list->map), removed_literal_compare);
- if (p)
+ if (removed_list->map != NULL)
{
- while (p != removed_list->map && (p - 1)->addr == addr)
- --p;
- r = p->literal;
+ p = bsearch (&addr, removed_list->map, removed_list->n_map,
+ sizeof (*removed_list->map), removed_literal_compare);
+ if (p)
+ {
+ while (p != removed_list->map && (p - 1)->addr == addr)
+ --p;
+ r = p->literal;
+ }
}
return r;
}