summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2013-07-16 08:19:55 +0000
committerTimo Teräs <timo.teras@iki.fi>2013-07-17 08:30:53 +0300
commit21d4e9243ae7445d9a797a169177501022d6e2fa (patch)
tree9024e7ff0dc24e55d01a00e6930ec2d462029202 /src
parent7086a19ff6dd2bc90a87e0ca58ebd4b65d0bcb8c (diff)
downloadapk-tools-21d4e9243ae7445d9a797a169177501022d6e2fa.tar.gz
apk-tools-21d4e9243ae7445d9a797a169177501022d6e2fa.tar.bz2
apk-tools-21d4e9243ae7445d9a797a169177501022d6e2fa.tar.xz
apk-tools-21d4e9243ae7445d9a797a169177501022d6e2fa.zip
db: fix segfault when --root points to invalid dir
fixes #2134
Diffstat (limited to 'src')
-rw-r--r--src/database.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/database.c b/src/database.c
index 33f7af8..d8b84b5 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1740,7 +1740,9 @@ void apk_db_close(struct apk_database *db)
struct hlist_node *dc, *dn;
int i;
- apk_id_cache_free(&db->id_cache);
+ /* the id cache was never initialized if root_fd failed */
+ if (db->root_fd >= 0)
+ apk_id_cache_free(&db->id_cache);
/* Cleaning up the directory tree will cause mode, uid and gid
* of all modified (package providing that directory got removed)