Skip to content

Commit

Permalink
Unify freeing of target->zck_dl to a single place
Browse files Browse the repository at this point in the history
Apart from these two places the `zck_dl` is leaking through other code
paths. Handle it and stuff it contains in a single place.
  • Loading branch information
kontura committed Aug 1, 2024
1 parent 1e15c18 commit ee0a5b6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 0 additions & 4 deletions librepo/downloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,8 +1357,6 @@ check_zck(LrTarget *target, GError **err)

if(cks_good == 1) { // All checksums good
g_debug("%s: File is complete", __func__);
if(target->target->zck_dl)
zck_dl_free(&(target->target->zck_dl));
target->zck_state = LR_ZCK_DL_FINISHED;
return TRUE;
}
Expand All @@ -1378,8 +1376,6 @@ check_zck(LrTarget *target, GError **err)
}

if(cks_good == 1) { // All checksums good
if(target->target->zck_dl)
zck_dl_free(&(target->target->zck_dl));
target->zck_state = LR_ZCK_DL_FINISHED;
return TRUE;
}
Expand Down
20 changes: 20 additions & 0 deletions librepo/downloadtarget.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,26 @@ lr_downloadtarget_free(LrDownloadTarget *target)
if (!target)
return;

#ifdef WITH_ZCHUNK
if (target->zck_dl) {
zckCtx *zck = zck_dl_get_zck(target->zck_dl);
if (zck) {
zck_free(&zck);
}

zckRange *range = zck_dl_get_range(target->zck_dl);
if(range) {
zck_range_free(&range);
}

zck_dl_free(&target->zck_dl);
}
#endif /* WITH_ZCHUNK */

if(target->range) {
free(target->range);
}

g_slist_free_full(target->checksums,
(GDestroyNotify) lr_downloadtargetchecksum_free);
g_string_chunk_free(target->chunk);
Expand Down

0 comments on commit ee0a5b6

Please sign in to comment.