summaryrefslogtreecommitdiff
path: root/src/del.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2013-06-19 10:53:50 +0300
committerTimo Teräs <timo.teras@iki.fi>2013-06-19 11:01:08 +0300
commit0c1a26f25c73710896d8666b2de11e5215eda366 (patch)
treea6253a8fdae1e991b2b54b00c01b5ca84922a630 /src/del.c
parent0e9d67aea8137bf00c2082395d2605b7a1a028c0 (diff)
downloadapk-tools-0c1a26f25c73710896d8666b2de11e5215eda366.tar.gz
apk-tools-0c1a26f25c73710896d8666b2de11e5215eda366.tar.bz2
apk-tools-0c1a26f25c73710896d8666b2de11e5215eda366.tar.xz
apk-tools-0c1a26f25c73710896d8666b2de11e5215eda366.zip
del: fix a segfault when trying to delete uninstalled packages
Diffstat (limited to 'src/del.c')
-rw-r--r--src/del.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/del.c b/src/del.c
index 4e4da08..02d34a7 100644
--- a/src/del.c
+++ b/src/del.c
@@ -81,6 +81,7 @@ static int del_main(void *pctx, struct apk_database *db, struct apk_string_array
struct not_deleted_ctx ndctx = {};
struct apk_name_array *names;
struct apk_name **pname;
+ struct apk_package *pkg;
struct apk_changeset changeset = {};
struct apk_change *change;
struct apk_provider *p;
@@ -92,7 +93,9 @@ static int del_main(void *pctx, struct apk_database *db, struct apk_string_array
for (i = 0; i < args->num; i++) {
names->item[i] = apk_db_get_name(db, APK_BLOB_STR(args->item[i]));
- delete_from_world(apk_pkg_get_installed(names->item[i]), NULL, NULL, ctx);
+ pkg = apk_pkg_get_installed(names->item[i]);
+ if (pkg != NULL)
+ delete_from_world(pkg, NULL, NULL, ctx);
}
r = apk_solver_solve(db, 0, ctx->world, &changeset);