PR26508 UBSAN: tc-xtensa.c:7764 null pointer bsearch
authorAlan Modra <amodra@gmail.com>
Wed, 26 Aug 2020 10:58:40 +0000 (20:28 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 26 Aug 2020 13:53:45 +0000 (23:23 +0930)
PR 26508
* config/tc-xtensa.c (xg_get_trampoline_chain): Return early
when n_entries is zero.

gas/ChangeLog
gas/config/tc-xtensa.c

index c56b992685cb302e6f6d8797dfd2f2bc6d3b65a7..c0d9b26a29c31c54073e54949658927b1520fcaa 100644 (file)
@@ -1,3 +1,9 @@
+2020-08-26  Alan Modra  <amodra@gmail.com>
+
+       PR 26508
+       * config/tc-xtensa.c (xg_get_trampoline_chain): Return early
+       when n_entries is zero.
+
 2020-08-26  Alan Modra  <amodra@gmail.com>
 
        PR 26448
index 82ec43933220c42b4d12e1be305500782853d484..af4c66721a68b08d25406c6de38e6fa0eb3c10ae 100644 (file)
@@ -7753,6 +7753,9 @@ xg_get_trampoline_chain (struct trampoline_seg *ts,
   struct trampoline_chain_index *idx = &ts->chain_index;
   struct trampoline_chain c;
 
+  if (idx->n_entries == 0)
+    return NULL;
+
   if (idx->needs_sorting)
     {
       qsort (idx->entry, idx->n_entries, sizeof (*idx->entry),