From: Zdenek Dohnal Date: Mon, 30 Oct 2023 10:34:55 +0000 (+0100) Subject: scheduler/job.c: unload job before freeing job history in cupsdDeleteJob() X-Git-Tag: v2.4.8~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=920dd4e6aeb5e04ca6cf9fbf88b03b6f79b3a89d;p=thirdparty%2Fcups.git scheduler/job.c: unload job before freeing job history in cupsdDeleteJob() With "PreserveJobHistory Off", LogLevel not set to debug (or debug2), and "LogDebugHistory 200" (the default), cupsdDeleteJob() frees the job history and then unloads the job. However, unload_job() calls cupsdLogJob() which re-creates the job history and puts "Unloading..." into it because level (debug) is greater than LogLevel (warn) and LogDebugHistory is set to 200 messages by default. Unused (and unreachable) job history is left behind, resulting in a memory leak. --- diff --git a/CHANGES.md b/CHANGES.md index 2daa4a86bb..d57542ab2f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ CHANGES - OpenPrinting CUPS 2.4.8 - TBA Changes in CUPS v2.4.8 (TBA) ---------------------------- +- Fixed memory leak when unloading a job (Issue #813) - Raised `cups_enum_dests()` timeout for listing available IPP printers (Issue #751) - Really backport fix for Issue #742 diff --git a/scheduler/job.c b/scheduler/job.c index 49e4fa3379..768b099651 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -1420,11 +1420,11 @@ cupsdDeleteJob(cupsd_job_t *job, /* I - Job */ job->num_files = 0; } + unload_job(job); + if (job->history) free_job_history(job); - unload_job(job); - cupsArrayRemove(Jobs, job); cupsArrayRemove(ActiveJobs, job); cupsArrayRemove(PrintingJobs, job);