From bf84dc4cf1b925cc3ac1fb3185efc50a21802ba4 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 14 Oct 2011 14:50:27 -0500 Subject: Make _alpm_filelist_contains() NULL-safe Signed-off-by: Dan McGee --- lib/libalpm/conflict.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index 14c23f45..f686ca82 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -318,12 +318,16 @@ const alpm_file_t *_alpm_filelist_contains(alpm_filelist_t *filelist, const char *name) { size_t i; - const alpm_file_t *file = filelist->files; - for(i = 0; i < filelist->count; i++) { + const alpm_file_t *file; + + if(!filelist) { + return NULL; + } + + for(file = filelist->files, i = 0; i < filelist->count; file++, i++) { if(strcmp(file->name, name) == 0) { return file; } - file++; } return NULL; } -- cgit v1.2.3-70-g09d2