db: fix segfault when --root points to invalid dir

fixes #2134
cute-signatures
Natanael Copa 2013-07-16 08:19:55 +00:00 committed by Timo Teräs
parent 7086a19ff6
commit 21d4e9243a
1 changed files with 3 additions and 1 deletions

View File

@ -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)