From e637b7ba2f8399ba94721be3f1765b471b6a67c2 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 26 Aug 2020 20:28:40 +0930 Subject: [PATCH] PR26508 UBSAN: tc-xtensa.c:7764 null pointer bsearch PR 26508 * config/tc-xtensa.c (xg_get_trampoline_chain): Return early when n_entries is zero. --- gas/ChangeLog | 6 ++++++ gas/config/tc-xtensa.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/gas/ChangeLog b/gas/ChangeLog index c56b992685c..c0d9b26a29c 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2020-08-26 Alan Modra + + PR 26508 + * config/tc-xtensa.c (xg_get_trampoline_chain): Return early + when n_entries is zero. + 2020-08-26 Alan Modra PR 26448 diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c index 82ec4393322..af4c66721a6 100644 --- a/gas/config/tc-xtensa.c +++ b/gas/config/tc-xtensa.c @@ -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), -- 2.30.2