summaryrefslogtreecommitdiffstats
path: root/source/ap/ghostscript/9b6fe6e1008f1b9b7fc3109b5f94db8d970fbcaa.patch
blob: 352dbd8662e6cf5cc3aa85da2b3725f44efa39a6 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From 9b6fe6e1008f1b9b7fc3109b5f94db8d970fbcaa Mon Sep 17 00:00:00 2001
From: Ken Sharp <Ken.Sharp@artifex.com>
Date: Mon, 18 Sep 2023 15:47:12 +0100
Subject: [PATCH] PDF interpreter - fix PageList processing

Bug #707137 "Error processing PDF while using the parameter -sPageList"

There are actually 2 problems; firstly a copy/paste error of the
operand stack index when returning the page list meant that the values
were returned in reverse order.

Secondly the PageList string wasn't actually being passed as an operand
at all.

This only affects the PDF interpreter because it (unfortunately) uses a
different mechanism from the PostScript interpreter.
---
 Resource/Init/pdf_main.ps | 3 +--
 psi/zpdfops.c             | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps
index e541835ae..73097f1a7 100644
--- a/Resource/Init/pdf_main.ps
+++ b/Resource/Init/pdf_main.ps
@@ -710,8 +710,7 @@ currentdict /PDFSwitches undef
 {
   /PageList where {
     pop
-    pdfpagecount
-    .PDFparsePageList
+    PageList pdfpagecount .PDFparsePageList
     dup 0 eq {	% No ranges, error
       (\n   **** Error: Invalid PageList: ) print
       PageList  print
diff --git a/psi/zpdfops.c b/psi/zpdfops.c
index 207130f1a..e7e0a42ee 100644
--- a/psi/zpdfops.c
+++ b/psi/zpdfops.c
@@ -1447,7 +1447,7 @@ static int zPDFparsePageList(i_ctx_t *i_ctx_p)
     }
     /* push the even/odd, start, end triples on the stack */
     for (i=0; i < size;  i++) {
-        o = ref_stack_index(&o_stack, 0);
+        o = ref_stack_index(&o_stack, size - i);
         if (o == NULL)
             return_error(gs_error_stackunderflow);
         /* skip the initial "ordered" flag */
-- 
2.34.1