Skip to content

Commit

Permalink
Free zckCtx from zckDL before overwriting it
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kontura committed Jul 22, 2024
1 parent 2fd52f2 commit 1e15c18
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions librepo/downloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 1e15c18

Please sign in to comment.