From e16b95ddbbfa0ffc0a9354d06172d271cc77b9df Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Wed, 3 Apr 2024 01:23:16 +1000 Subject: [PATCH] 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 (cherry picked from commit 0ccb584262cefdd09674cdf21406ae69577b10ad) --- lib/libalpm/filelist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libalpm/filelist.c b/lib/libalpm/filelist.c index 13990671..5d781235 100644 --- a/lib/libalpm/filelist.c +++ b/lib/libalpm/filelist.c @@ -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; }