diff options
author | Dan McGee <dan@archlinux.org> | 2011-10-14 14:50:27 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-10-14 14:50:27 -0500 |
commit | bf84dc4cf1b925cc3ac1fb3185efc50a21802ba4 (patch) | |
tree | 0187396622fdee56e785b07e625f6a97a367ab41 /lib | |
parent | a33424f87955c43652a61fcef5817df07e17bee3 (diff) | |
download | pacman-bf84dc4cf1b925cc3ac1fb3185efc50a21802ba4.tar.xz |
Make _alpm_filelist_contains() NULL-safe
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libalpm/conflict.c | 10 |
1 files 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; } |