summaryrefslogtreecommitdiff
path: root/pcl
diff options
context:
space:
mode:
authorJulian Smith <julian.smith@artifex.com>2022-01-31 14:44:35 +0000
committerJulian Smith <julian.smith@artifex.com>2022-02-01 12:09:58 +0000
commit69f621e1f2e4be9aae3e57ca1c33b5514e06bcf8 (patch)
tree3deddb0cf234301b68715f4d26fced1c26c8f3fd /pcl
parent092b4890aa824a020daa4171c51781fdbff6e1bd (diff)
downloadghostpdl-69f621e1f2e4be9aae3e57ca1c33b5514e06bcf8.tar.gz
pcl/pcl/: fix Memento leak of pst->args.data.
pcl_impl_process_eof(): free pcli->pst.args.data before calling process_init(). Also removed pcl_parser_init_inline() macro and replaced with explicit code in the single call site in pcl_process_init(). Fixes: ghostpdl/mem-extract-bin/gpcl6 -dNOPAUSE -dBATCH -sDEVICE=ppmraw -dMaxBitmap=1000 -r300 -o gpcl6.out tests_private/customer_tests/bug693543.pcl
Diffstat (limited to 'pcl')
-rw-r--r--pcl/pcl/pcparse.c8
-rw-r--r--pcl/pcl/pcparse.h5
-rw-r--r--pcl/pcl/pctop.c5
3 files changed, 11 insertions, 7 deletions
diff --git a/pcl/pcl/pcparse.c b/pcl/pcl/pcparse.c
index 9488aec96..2a5be65b0 100644
--- a/pcl/pcl/pcparse.c
+++ b/pcl/pcl/pcparse.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
@@ -205,7 +205,11 @@ pcl_process_init(pcl_parser_state_t * pst, pcl_state_t * pcs)
{
pcl_args_t args;
int code = 0;
- pcl_parser_init_inline(pst);
+ pst->scan_type = scanning_none;
+ pst->args.data = 0;
+ pst->args.data_on_heap = false;
+ pst->short_hand = false;
+ pst->min_bytes_needed = 0;
/*
* RTL Files should start with a PCL escape sequence to enter the
diff --git a/pcl/pcl/pcparse.h b/pcl/pcl/pcparse.h
index 989dd4e50..3bb86aafd 100644
--- a/pcl/pcl/pcparse.h
+++ b/pcl/pcl/pcparse.h
@@ -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
@@ -88,9 +88,6 @@ struct pcl_parser_state_s
pcl_command_definitions_t *definitions;
};
-#define pcl_parser_init_inline(pst)\
- ((pst)->scan_type = scanning_none, (pst)->args.data = 0, (pst)->args.data_on_heap = false, (pst)->short_hand = false, (pst)->min_bytes_needed = 0)
-
/* Define the prefix of a macro definition. */
typedef struct pcl_macro_s
{
diff --git a/pcl/pcl/pctop.c b/pcl/pcl/pctop.c
index ef6c488b9..58a920008 100644
--- a/pcl/pcl/pctop.c
+++ b/pcl/pcl/pctop.c
@@ -483,7 +483,10 @@ pcl_impl_process_eof(pl_interp_implementation_t * impl /* interp instance to
)
{
pcl_interp_instance_t *pcli = impl->interp_client_data;
- int code = pcl_process_init(&pcli->pst, &pcli->pcs);
+ int code;
+ if (pcli->pst.args.data_on_heap)
+ gs_free_object(pcli->memory, pcli->pst.args.data, "command data");
+ code = pcl_process_init(&pcli->pst, &pcli->pcs);
if (code < 0)
return code;
/* force restore & cleanup if unexpected data end was encountered */