summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/db.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-08-19 18:06:55 +0200
committerDan McGee <dan@archlinux.org>2011-08-19 18:09:57 +0200
commit6d544984f2418ea34caab4c433580487b760362a (patch)
treecf0510b97a6495587c87598a70bf8761189f5c32 /lib/libalpm/db.c
parent9934b3bd345011eef6a96249d8d90de594c04cd0 (diff)
downloadpacman-6d544984f2418ea34caab4c433580487b760362a.tar.gz
pacman-6d544984f2418ea34caab4c433580487b760362a.tar.xz
Be more robust when copying package data
This changes the signature of _alpm_pkg_dup() to return an integer error code and provide the new package in a passed pointer argument. All callers are now more robust with checking the return value of this function to ensure a fatal error did not occur. We allow load failures to proceed as otherwise we have a chicken and egg problem- if a 'desc' local database entry is missing, the best way of restoring said file is `pacman -Sf --dbonly packagename`. This patch fixes a segfault that was occurring in this case. Fixes the segfault reported in FS#25667. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/db.c')
-rw-r--r--lib/libalpm/db.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 77bdf98c..33282b87 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -553,8 +553,7 @@ int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg)
return -1;
}
- newpkg = _alpm_pkg_dup(pkg);
- if(newpkg == NULL) {
+ if(_alpm_pkg_dup(pkg, &newpkg)) {
return -1;
}