Fix for 687016, epswrite fails with 001-01.ps

Alex Cherepanov <[email protected]>
Newsgroups gmane.comp.printing.ghostscript.patches
Message-ID <[email protected]>
Prevent operand stack overflow.
Issue a path construction command after accumulation of 500 values.
Fix bug 687016

_______________________________________________
gs-code-review mailing list
[email protected]
http://www.ghostscript.com/mailman/listinfo/gs-code-review
gdevps.c.diff (text/plain, 1.1 KB)
Index: gs/src/gdevps.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevps.c,v
retrieving revision 1.36
diff -b -u -r1.36 gdevps.c
--- gs/src/gdevps.c	26 Aug 2003 12:37:13 -0000	1.36
+++ gs/src/gdevps.c	21 Oct 2003 05:32:51 -0000
@@ -40,6 +40,8 @@
 /* Current ProcSet version */
 #define PSWRITE_PROCSET_VERSION 1
 
+/* Guaranteed size of operand stack accoeding to PLRM */
+#define MAXOPSTACK 500
 
 private int psw_open_printer(gx_device * dev);
 private int psw_close_printer(gx_device * dev);
@@ -831,7 +833,12 @@
 	stream *s = gdev_vector_stream(vdev);
 	gx_device_pswrite *const pdev = (gx_device_pswrite *)vdev;
 
-	if (pdev->path_state.num_points > 0 &&
+	if (pdev->path_state.num_points > MAXOPSTACK / 2 - 10) {
+ 	    stream_puts(s, (pdev->path_state.move ? "P\n" : "p\n"));
+            pdev->path_state.num_points = 0;
+            pdev->path_state.move = 0;
+        }
+        else if (pdev->path_state.num_points > 0 &&
 	    !(pdev->path_state.num_points & 7)
 	    )
 	    stream_putc(s, '\n');	/* limit line length for DSC compliance */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.