summaryrefslogtreecommitdiff
path: root/pcl
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2022-01-26 16:07:44 +0000
committerRobin Watts <Robin.Watts@artifex.com>2022-01-26 17:07:47 +0000
commita144cf45b94772a7f91a50ffd7a3a132cb660245 (patch)
tree270037cede638bd2c636bab0787107c1cd825528 /pcl
parente2dcca3031f485e2c8ababb7afe3836b7712ea4f (diff)
downloadghostpdl-a144cf45b94772a7f91a50ffd7a3a132cb660245.tar.gz
PCL6: Fix memory leaks on closedown of interpreter.
We were not clearing the bi_pattern_array, which caused lots of state to be retained.
Diffstat (limited to 'pcl')
-rw-r--r--pcl/pcl/pcl.mak1
-rw-r--r--pcl/pcl/pctop.c4
-rw-r--r--pcl/pcl/pcuptrn.c4
3 files changed, 8 insertions, 1 deletions
diff --git a/pcl/pcl/pcl.mak b/pcl/pcl/pcl.mak
index f2542c9eb..47b3dde09 100644
--- a/pcl/pcl/pcl.mak
+++ b/pcl/pcl/pcl.mak
@@ -730,6 +730,7 @@ $(PCL_TOP_OBJ): $(PCLSRC)pctop.c \
$(rtgmode_h) \
$(gsicc_manage_h) \
$(pconfig_h) \
+ $(pcuptrn_h) \
$(PCL_MAK) \
$(MAKEDIRS)
$(PCLCCC) $(PCLSRC)pctop.c $(PCLO_)pctop.$(OBJ)
diff --git a/pcl/pcl/pctop.c b/pcl/pcl/pctop.c
index d9190b12a..f5750e3d8 100644
--- a/pcl/pcl/pctop.c
+++ b/pcl/pcl/pctop.c
@@ -42,6 +42,7 @@
#include "rtgmode.h"
#include "gsicc_manage.h"
#include "pcparam.h"
+#include "pcuptrn.h"
/* Configuration table for modules */
extern const pcl_init_t pcparse_init;
@@ -547,6 +548,7 @@ pcl_impl_deallocate_interp_instance(pl_interp_implementation_t * impl /* ins
{
pcl_interp_instance_t *pcli = impl->interp_client_data;
gs_memory_t *mem = pcli->memory;
+ int i;
/* free memory used by the parsers */
if (pcl_parser_shutdown(&pcli->pst, mem) < 0) {
@@ -593,6 +595,8 @@ pcl_impl_deallocate_interp_instance(pl_interp_implementation_t * impl /* ins
gs_font_dir_free(pcli->pcs.font_dir);
gx_path_free(&pcli->pcs.g.polygon.buffer.path, "pcl_deallocate_interp_instance");
+ for (i = 0; i < sizeof(pcli->pcs.bi_pattern_array)/sizeof(*pcli->pcs.bi_pattern_array); i++)
+ pcl_pattern_free_pattern(pcli->pcs.memory, pcli->pcs.bi_pattern_array[i], "destroy PCL pattern");
gs_free_object(mem, pcli,
"pcl_deallocate_interp_instance(pcl_interp_instance_t)");
return 0;
diff --git a/pcl/pcl/pcuptrn.c b/pcl/pcl/pcuptrn.c
index 420d698b0..d0efa1bfc 100644
--- a/pcl/pcl/pcuptrn.c
+++ b/pcl/pcl/pcuptrn.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2021 Artifex Software, Inc.
+/* Copyright (C) 2001-2022 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -111,6 +111,8 @@ pcl_pattern_free_pattern(gs_memory_t * pmem,
{
pcl_pattern_t *pptrn = (pcl_pattern_t *) pvptrn;
+ if (pptrn == NULL)
+ return;
free_pattern_rendering(pmem, pptrn);
if (pptrn->ppat_data != 0)
pcl_pattern_data_release(pptrn->ppat_data);