summaryrefslogtreecommitdiff
path: root/lib/libalpm/be_sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/be_sync.c')
-rw-r--r--lib/libalpm/be_sync.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 25c8cbec..b09b0608 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -721,9 +721,13 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
files_count++;
}
/* attempt to hand back any memory we don't need */
- files = realloc(files, sizeof(alpm_file_t) * files_count);
- /* make sure the list is sorted */
- qsort(files, files_count, sizeof(alpm_file_t), _alpm_files_cmp);
+ if(files_count > 0) {
+ files = realloc(files, sizeof(alpm_file_t) * files_count);
+ /* make sure the list is sorted */
+ qsort(files, files_count, sizeof(alpm_file_t), _alpm_files_cmp);
+ } else {
+ FREE(files);
+ }
pkg->files.count = files_count;
pkg->files.files = files;
}