index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2015-11-01 20:41:55 -0500 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2015-11-03 21:45:09 +1000 |
commit | 6eac7258cd3ae1cb63e59fceb68cc5d144a9dd4f (patch) | |
tree | 73dbc7a429b1af1045f637b6c5ece14f8254d79a /lib | |
parent | 0fd6d354a6b8de976ec9b6a146c4cb8cdcdd5ebb (diff) |
-rw-r--r-- | lib/libalpm/be_local.c | 10 | ||||
-rw-r--r-- | lib/libalpm/be_sync.c | 10 |
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index 556157d8..e35fc0e4 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -810,9 +810,13 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq) 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); + } info->files.count = files_count; info->files.files = files; } else if(strcmp(line, "%BACKUP%") == 0) { 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; } |