summaryrefslogtreecommitdiff
path: root/gs/src/gdevprn.c
diff options
context:
space:
mode:
authorRay Johnston <ray.johnston@artifex.com>2007-03-04 16:41:00 +0000
committerRay Johnston <ray.johnston@artifex.com>2007-03-04 16:41:00 +0000
commit3a9ee49792d59780d1084503ce6ad6465a3740a0 (patch)
tree379a5981b83f6e9a3aa51001097c9df598e4a6c4 /gs/src/gdevprn.c
parent3644c1770cfe6ea644891f3fdc2a37803d0bded1 (diff)
Free up any previous line_ptrs in a memory (image) device before
allocating new ones. This allows multiple calls to setup_buf_device without leaking memory (as seen with the PCL allocator that does not have garbage collection). git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@7759 a1074d23-0009-0410-80fe-cf8c14f379e6
Diffstat (limited to 'gs/src/gdevprn.c')
-rw-r--r--gs/src/gdevprn.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gs/src/gdevprn.c b/gs/src/gdevprn.c
index ecdcbe8fb..b0d7c551e 100644
--- a/gs/src/gdevprn.c
+++ b/gs/src/gdevprn.c
@@ -1081,6 +1081,13 @@ gx_default_setup_buf_device(gx_device *bdev, byte *buffer, int bytes_per_line,
if ((gx_device *)mdev == bdev && mdev->num_planes)
raster = bitmap_raster(mdev->planes[0].depth * mdev->width);
if (ptrs == 0) {
+ /*
+ * Before allocating a new line pointer array, if there is a previous
+ * array, free it to prevent leaks.
+ */
+ if (mdev->line_ptrs != NULL)
+ gs_free_object(mdev->line_pointer_memory, mdev->line_ptrs,
+ "mem_close");
/*
* Allocate line pointers now; free them when we close the device.
* Note that for multi-planar devices, we have to allocate using