From b291d2bcaa9c22e2a16aa081d19ce9d25d4873bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= Date: Fri, 19 Jul 2024 11:10:20 +0200 Subject: [PATCH] Free `zckCtx` from `zckDL` before overwriting it Since the `zckCtx` from `zckDL` is referenced only in `zckDL` and there is only a single `zckDL` per `LrDownloadTarget` we have to free previous `zckCtx` before overwriting it. Otherwise it leaks. --- librepo/downloader.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/librepo/downloader.c b/librepo/downloader.c index 1d696539..7208a407 100644 --- a/librepo/downloader.c +++ b/librepo/downloader.c @@ -1139,6 +1139,8 @@ prep_zck_header(LrTarget *target, GError **err) zck = lr_zck_init_read(target->target, target->target->path, fd, &tmp_err); if(zck) { + zckCtx *old_zck = zck_dl_get_zck(target->target->zck_dl); + zck_free(&old_zck); if(!zck_dl_set_zck(target->target->zck_dl, zck)) { g_set_error(err, LR_DOWNLOADER_ERROR, LRE_ZCK, "Unable to setup zchunk download context");