Do not pass NULL paramenter to bsearch with empty filelist

A filelist can be non-NULL but empty (particularly with a lot of
NoExtract entries). Handle this in alpm_filelist_contains()

Identified using the undefined behaviour sanitizer.

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2024-04-03 01:23:16 +10:00
parent 27eba85594
commit 0ccb584262

View File

@ -123,7 +123,7 @@ alpm_file_t SYMEXPORT *alpm_filelist_contains(const alpm_filelist_t *filelist,
{
alpm_file_t key;
if(!filelist) {
if(!filelist || filelist->count == 0) {
return NULL;
}