From 5748317e77a36b80b1459902dc6d6ad7c1634296 Mon Sep 17 00:00:00 2001 From: Mole Shang <135e2@135e2.dev> Date: Thu, 10 Aug 2023 14:40:44 +0800 Subject: process_url: do not run callback if corrupted --- src/process_url.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/process_url.c b/src/process_url.c index 9b1fa86..135c181 100644 --- a/src/process_url.c +++ b/src/process_url.c @@ -387,7 +387,6 @@ static int merge_and_cleanup(curl_conf_t **p_curl_c) { } append_log("Download %s finished.\n", curl_conf->outfn); // Reset stat - corrupted = false; curl_c->success_thrd = 0; curl_c->total_thrd = 0; free_and_nullify((void **)&curl_c->URL); @@ -544,11 +543,12 @@ void poll_status(status_t *stat) { } merge_and_cleanup(&curl_conf); // Perform the callback - if (is_empty_queue(&dl_queue) && callback_g) { + if (is_empty_queue(&dl_queue) && callback_g && !corrupted) { thrd_t cb_thrd; thrd_create(&cb_thrd, callback_g, p_callback_struct_g); thrd_detach(cb_thrd); } + corrupted = false; } mtx_unlock(&mtx); } -- cgit v1.2.3