From 5496560a4fa8fee3f3e60c2092f413f4aa76c088 Mon Sep 17 00:00:00 2001 From: Timo Teräs Date: Tue, 7 Oct 2014 17:05:06 +0300 Subject: db: fix crash if unable to download cache item fixes #3371 --- src/database.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') 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; -- cgit v1.2.3-60-g2f50