aboutsummaryrefslogtreecommitdiff
path: root/ld/pe-dll.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-08-26 14:23:42 +0930
committerAlan Modra <amodra@gmail.com>2020-08-26 23:23:44 +0930
commitaaf9875ef9252ec42bafac076421cc5ff22965ad (patch)
tree58096aa2a533deff2b72397bb2a5ecd561599b86 /ld/pe-dll.c
parent9863cbb7bd3495107a5b1b4d887c95d859c9a35e (diff)
downloadgdb-aaf9875ef9252ec42bafac076421cc5ff22965ad.zip
gdb-aaf9875ef9252ec42bafac076421cc5ff22965ad.tar.gz
gdb-aaf9875ef9252ec42bafac076421cc5ff22965ad.tar.bz2
PR26431 UBSAN: pe-dll.c:568 null pointer bsearch
PR 26431 * pe-dll.c (auto_export): Don't call bsearch with zero count.
Diffstat (limited to 'ld/pe-dll.c')
-rw-r--r--ld/pe-dll.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index 3e8fe1b..39c8e4c 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -565,8 +565,9 @@ auto_export (bfd *abfd, def_file *d, const char *n)
key.name = key.its_name = (char *) n;
/* Return false if n is in the d->exports table. */
- if (bsearch (&key, d->exports, d->num_exports,
- sizeof (pe_def_file->exports[0]), pe_export_sort))
+ if (d->num_exports != 0
+ && bsearch (&key, d->exports, d->num_exports,
+ sizeof (pe_def_file->exports[0]), pe_export_sort))
return 0;
if (pe_dll_do_default_excludes)