[pacman-dev] [PATCH 1/2] Make _alpm_filelist_contains() NULL-safe
Dan McGee
dan at archlinux.org
Fri Oct 14 15:57:13 EDT 2011
Signed-off-by: Dan McGee <dan at archlinux.org>
---
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 14c23f4..f686ca8 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;
}
--
1.7.7
More information about the pacman-dev
mailing list