summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2010-06-01 16:46:53 +0300
committerTimo Teräs <timo.teras@iki.fi>2010-06-01 16:46:53 +0300
commitce3cf8bff901e7fcacbca640ffedaeea2b3bdf7f (patch)
tree4b218df4631da29ddaf80c4514430f43f93ed29f
parent440cffef5891dab07631e17f83845f9f95f89b0d (diff)
downloadapk-tools-ce3cf8bff901e7fcacbca640ffedaeea2b3bdf7f.tar.gz
apk-tools-ce3cf8bff901e7fcacbca640ffedaeea2b3bdf7f.tar.bz2
apk-tools-ce3cf8bff901e7fcacbca640ffedaeea2b3bdf7f.tar.xz
apk-tools-ce3cf8bff901e7fcacbca640ffedaeea2b3bdf7f.zip
db, pkg: fix triggers related crash
clean up the triggers properly, in proper order.
-rw-r--r--src/database.c18
-rw-r--r--src/package.c1
2 files changed, 11 insertions, 8 deletions
diff --git a/src/database.c b/src/database.c
index ae7bbfc..46ad98c 100644
--- a/src/database.c
+++ b/src/database.c
@@ -831,7 +831,8 @@ static void apk_db_triggers_write(struct apk_database *db, struct apk_ostream *o
list_for_each_entry(ipkg, &db->installed.triggers, trigger_pkgs_list) {
bfn = APK_BLOB_BUF(buf);
apk_blob_push_csum(&bfn, &ipkg->pkg->csum);
- os->write(os, buf, bfn.ptr - buf);
+ bfn = apk_blob_pushed(APK_BLOB_BUF(buf), bfn);
+ os->write(os, bfn.ptr, bfn.len);
for (i = 0; i < ipkg->triggers->num; i++) {
os->write(os, " ", 1);
@@ -1269,8 +1270,8 @@ void apk_db_close(struct apk_database *db)
if (db->world)
free(db->world);
- apk_hash_free(&db->available.names);
apk_hash_free(&db->available.packages);
+ apk_hash_free(&db->available.names);
apk_hash_free(&db->installed.files);
apk_hash_free(&db->installed.dirs);
@@ -2106,12 +2107,6 @@ int apk_db_install_pkg(struct apk_database *db,
/* Install the new stuff */
ipkg = apk_pkg_install(db, newpkg);
- ipkg->flags |= APK_IPKGF_RUN_ALL_TRIGGERS;
- if (ipkg->triggers) {
- list_del(&ipkg->trigger_pkgs_list);
- free(ipkg->triggers);
- ipkg->triggers = NULL;
- }
if (newpkg->installed_size != 0) {
r = apk_db_unpack_pkg(db, ipkg, (oldpkg != NULL),
(oldpkg == newpkg), cb, cb_ctx,
@@ -2122,6 +2117,13 @@ int apk_db_install_pkg(struct apk_database *db,
}
}
+ ipkg->flags |= APK_IPKGF_RUN_ALL_TRIGGERS;
+ if (ipkg->triggers) {
+ list_del(&ipkg->trigger_pkgs_list);
+ free(ipkg->triggers);
+ ipkg->triggers = NULL;
+ }
+
if (oldpkg != NULL && oldpkg != newpkg && oldpkg->ipkg != NULL) {
apk_db_purge_pkg(db, oldpkg->ipkg, NULL);
apk_pkg_uninstall(db, oldpkg);
diff --git a/src/package.c b/src/package.c
index b608fb8..cc79d05 100644
--- a/src/package.c
+++ b/src/package.c
@@ -92,6 +92,7 @@ void apk_pkg_uninstall(struct apk_database *db, struct apk_package *pkg)
if (ipkg->triggers) {
list_del(&ipkg->trigger_pkgs_list);
+ list_init(&ipkg->trigger_pkgs_list);
for (i = 0; i < ipkg->triggers->num; i++)
free(ipkg->triggers->item[i]);
free(ipkg->triggers);