public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PR26507 UBSAN: elf32-xtensa.c:6013 null pointer bsearch
@ 2020-08-26 13:52 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2020-08-26 13:52 UTC (permalink / raw)
  To: binutils

	PR 26507
	* elf32-xtensa.c (find_removed_literal): Don't bsearch empty map.

diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 5184fbf1be..5824c599ca 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;
 }

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-26 13:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26 13:52 PR26507 UBSAN: elf32-xtensa.c:6013 null pointer bsearch Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).