summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2022-08-20 11:05:33 +0100
committerKen Sharp <ken.sharp@artifex.com>2022-08-20 11:06:55 +0100
commit644970756fcbd70e3eb7371031b7b7cd68c54232 (patch)
tree6ed643809363d0d327f830a2900b7def67a08b38
parenteba3379360caec1d881d96c5d51ed4282278cd1f (diff)
downloadghostpdl-644970756fcbd70e3eb7371031b7b7cd68c54232.tar.gz
ps2write - fix PSPageOptions with multi-page input
Commit 7d6d69ff17c43664482fe0dc34676a46ba551d93 accidentally broke PSPageOptions with multi-page input, because the array of strings was freed on every page. This commit fixes that problem; note you cannot change PSPageOptions once it has been set, except by restoring back to the point before the device was opened. Also the documentation formatting was slightly broken, fix that at the same time.
-rw-r--r--devices/vector/gdevpsdp.c20
-rw-r--r--doc/VectorDevices.htm4
2 files changed, 14 insertions, 10 deletions
diff --git a/devices/vector/gdevpsdp.c b/devices/vector/gdevpsdp.c
index fc944539e..cf6933ece 100644
--- a/devices/vector/gdevpsdp.c
+++ b/devices/vector/gdevpsdp.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
@@ -1254,13 +1254,17 @@ gdev_psdf_put_params(gx_device * dev, gs_param_list * plist)
exit:
if (!(pdev->params.LockDistillerParams && params.LockDistillerParams)) {
/* Only update the device paramters if there was no error */
- /* If we have any copied param_string_arrays, start by freeing them */
- if (pdev->params.PSPageOptions.size && params.PSPageOptions.size) {
- int ix;
-
- for (ix = 0; ix < pdev->params.PSPageOptions.size;ix++)
- gs_free_object(mem->non_gc_memory, (byte *)pdev->params.PSPageOptions.data[ix].data, "freeing old string array copy");
- gs_free_object(mem->non_gc_memory, (byte *)pdev->params.PSPageOptions.data, "freeing old string array");
+ /* Do not permit changes to pdev->Params.PSPageOptions, it doesn't make any sense */
+ if (pdev->params.PSPageOptions.size != 0) {
+ if (params.PSPageOptions.size != 0 && params.PSPageOptions.data != pdev->params.PSPageOptions.data) {
+ int ix;
+
+ for (ix = 0; ix < pdev->params.PSPageOptions.size;ix++)
+ gs_free_object(mem->non_gc_memory, (byte *)params.PSPageOptions.data[ix].data, "freeing old string array copy");
+ gs_free_object(mem->non_gc_memory, (byte *)params.PSPageOptions.data, "freeing old string array");
+ }
+ params.PSPageOptions.data = pdev->params.PSPageOptions.data;
+ params.PSPageOptions.size = pdev->params.PSPageOptions.size;
}
pdev->params = params;
} else {
diff --git a/doc/VectorDevices.htm b/doc/VectorDevices.htm
index fd9b91629..437685f27 100644
--- a/doc/VectorDevices.htm
+++ b/doc/VectorDevices.htm
@@ -1117,21 +1117,21 @@ There are also two additional (not Adobe-standard) Distiller parameters, specifi
<dd>No default value. If defined, the contents of the string will be emitted in the output PostScript prolog
enclosed within %%BeginSetup and %%EndSetup comments. This is intended as a means of introducing device-specific document wide
setup or configuration options into the output. Default media selection, printer resolution etc might be included here.
+</dd>
<code>/PSPageOptions</code><em> array of strings</em>
-</dd>
<dd>No default value. If defined, the contents of the strings in the array will be emitted in the output PostScript at the start
of each page, one string per page, enclosed within %%BeginPageSetup and %%EndPageSetup comments. This is intended as a means of introducing device-specific
setup or configuration options into the output on a page by page basis. The strings are used from the array sequentially, if there are more
pages than strings then we 'wrap round' and start again with the first string. This makes it convenient to do setup for even/odd pages
by simply including 2 strings in the array.
+</dd>
<p>
Note: executing setpagedevice will reset distiller parameters to the default, if you use any of these options via setdistillerparams, and
expect to execute setpagedevice, you should set /LockDistillerParams true. Ordinarily the PDF interpreter executes setpagedevice for
every page in order to set the media size.
</p>
-</dd>
</dt>
</dl>