diff options
author | Timo Teräs <timo.teras@iki.fi> | 2014-10-07 17:05:06 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2014-10-07 17:05:06 +0300 |
commit | 5496560a4fa8fee3f3e60c2092f413f4aa76c088 (patch) | |
tree | b34abfa6f1a78e9320e67b1d5ebea46cbcd65786 | |
parent | 1bbca16333bb655b73bd80fc40d072fc697e4650 (diff) | |
download | apk-tools-5496560a4fa8fee3f3e60c2092f413f4aa76c088.tar.gz apk-tools-5496560a4fa8fee3f3e60c2092f413f4aa76c088.tar.bz2 apk-tools-5496560a4fa8fee3f3e60c2092f413f4aa76c088.tar.xz apk-tools-5496560a4fa8fee3f3e60c2092f413f4aa76c088.zip |
db: fix crash if unable to download cache item
fixes #3371
-rw-r--r-- | src/database.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/database.c b/src/database.c index 064957e..ef9f73c 100644 --- a/src/database.c +++ b/src/database.c @@ -638,7 +638,8 @@ int apk_cache_download(struct apk_database *db, struct apk_repository *repo, bs = apk_bstream_from_url(url); bs = apk_bstream_tee(bs, db->cache_fd, tmpcacheitem, cb, cb_ctx); is = apk_bstream_gunzip_mpart(bs, apk_sign_ctx_mpart_cb, &sctx); - r = apk_tar_parse(is, apk_sign_ctx_verify_tar, &sctx, FALSE, &db->id_cache); + if (is) r = apk_tar_parse(is, apk_sign_ctx_verify_tar, &sctx, FALSE, &db->id_cache); + else r = -errno; apk_sign_ctx_free(&sctx); } else { is = apk_istream_from_url(url); @@ -650,7 +651,7 @@ int apk_cache_download(struct apk_database *db, struct apk_repository *repo, r = -errno; } } - is->close(is); + if (is) is->close(is); if (r < 0) { unlinkat(db->cache_fd, tmpcacheitem, 0); return r; |