diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2022-01-13 16:54:02 +0000 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2022-01-13 23:51:24 +0000 |
commit | e039a404e7796d0435fa6f63b6f182ec59c14051 (patch) | |
tree | af52a6f5092aed5be893d38701c3e80fe94b90f6 /pcl | |
parent | 9c4eb789379cfd0902a4e4981d101d11fc7b01a4 (diff) | |
download | ghostpdl-e039a404e7796d0435fa6f63b6f182ec59c14051.tar.gz |
Fix some memory leaks with gpcl6.
When a memento build of gpcl6 is run with no arguments, we can
see that memory leaks. Here we fix some of those.
Firstly, free the font directory.
Secondly, free the paper type table.
Diffstat (limited to 'pcl')
-rw-r--r-- | pcl/pcl/pcpalet.c | 4 | ||||
-rw-r--r-- | pcl/pcl/pctop.c | 19 |
2 files changed, 22 insertions, 1 deletions
diff --git a/pcl/pcl/pcpalet.c b/pcl/pcl/pcpalet.c index 9d8363f62..554e2851f 100644 --- a/pcl/pcl/pcpalet.c +++ b/pcl/pcl/pcpalet.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 @@ -70,6 +70,8 @@ pcl_free_default_objects(gs_memory_t * mem, pcl_state_t * pcs) gs_free_object(mem, ppalette, "free_default_palette ppalette free"); pcs->pdflt_palette = 0; } + rc_decrement(pcs->pfrgrnd, "free foreground"); + rc_decrement(pcs->pdflt_frgrnd, "free default foreground"); /* what on earth is this? */ rc_decrement(pcs->pdflt_ht, "free_default_palette pdflt_ht release"); rc_decrement(pcs->pdflt_ht, "free_default_palette pdflt_ht release"); diff --git a/pcl/pcl/pctop.c b/pcl/pcl/pctop.c index f9f16a577..f953e1f47 100644 --- a/pcl/pcl/pctop.c +++ b/pcl/pcl/pctop.c @@ -556,9 +556,16 @@ pcl_impl_deallocate_interp_instance(pl_interp_implementation_t * impl /* ins pcli->pst.hpgl_parser_state, "pcl_deallocate_interp_instance(pcl_interp_instance_t)"); + pl_dict_release(&pcli->pcs.palette_store); + /* free default, pdflt_* objects */ pcl_free_default_objects(mem, &pcli->pcs); + if (pcli->pcs.ppaper_type_table) { + gs_free_object(pcli->pcs.memory, pcli->pcs.ppaper_type_table, "Paper Table"); + pcli->pcs.ppaper_type_table = 0; + } + /* Restore the gstate once, to match the extra 'gsave' done in * pcl_impl_allocate_interp_instance. */ gs_grestore_only(pcli->pcs.pgs); @@ -567,6 +574,18 @@ pcl_impl_deallocate_interp_instance(pl_interp_implementation_t * impl /* ins gs_gstate_free(pcli->pcs.pgs); /* remove pcl's gsave grestore stack */ pcl_free_gstate_stk(&pcli->pcs); + + /* Release font dictionaries. */ + pl_dict_release(&pcli->pcs.soft_symbol_sets); + pl_dict_release(&pcli->pcs.built_in_symbol_sets); + pl_dict_release(&pcli->pcs.simm_fonts); + pl_dict_release(&pcli->pcs.cartridge_fonts); + pl_dict_release(&pcli->pcs.soft_fonts); + pl_dict_release(&pcli->pcs.built_in_fonts); + + gs_font_dir_free(pcli->pcs.font_dir); + + gx_path_free(&pcli->pcs.g.polygon.buffer.path, "pcl_deallocate_interp_instance"); gs_free_object(mem, pcli, "pcl_deallocate_interp_instance(pcl_interp_instance_t)"); return 0; |