Make _alpm_filelist_contains() NULL-safe

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-10-14 14:50:27 -05:00
parent a33424f879
commit bf84dc4cf1

View file

@ -318,12 +318,16 @@ const alpm_file_t *_alpm_filelist_contains(alpm_filelist_t *filelist,
const char *name) const char *name)
{ {
size_t i; size_t i;
const alpm_file_t *file = filelist->files; const alpm_file_t *file;
for(i = 0; i < filelist->count; i++) {
if(!filelist) {
return NULL;
}
for(file = filelist->files, i = 0; i < filelist->count; file++, i++) {
if(strcmp(file->name, name) == 0) { if(strcmp(file->name, name) == 0) {
return file; return file;
} }
file++;
} }
return NULL; return NULL;
} }