Commit 5496560a authored by Timo Teräs's avatar Timo Teräs

db: fix crash if unable to download cache item

fixes #3371
parent 1bbca163
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment