]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
scheduler/job.c: unload job before freeing job history in cupsdDeleteJob()
authorZdenek Dohnal <zdohnal@redhat.com>
Mon, 30 Oct 2023 10:34:55 +0000 (11:34 +0100)
committerZdenek Dohnal <zdohnal@redhat.com>
Mon, 30 Oct 2023 10:34:55 +0000 (11:34 +0100)
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.

CHANGES.md
scheduler/job.c

index 2daa4a86bb09eb22d89c45bb8ed66591eb9b2d4f..d57542ab2fee8fe942e5d35b7e8105ab5ef3587e 100644 (file)
@@ -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
 
index 49e4fa3379521eb575f736d8f0ef375ede1829f5..768b099651cf2f329c47b0dacc3a0fc122d4045a 100644 (file)
@@ -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);