[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1722-gfbe920c

[email protected] (Ken Sharp) Fri, 11 Oct 2019 11:06:16 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  fbe920c86d42919620a425d0933d9dcbfaa1c3cb (commit)
      from  9dddc61852d012b867e0353c7897b9c5301e17e6 (commit)

----------------------------------------------------------------------
commit fbe920c86d42919620a425d0933d9dcbfaa1c3cb
Author: Ken Sharp <[email protected]>
Date:   Fri Oct 11 12:06:07 2019 +0100

    PDF interpreter - do not unconditionally restore state in update_alpha
    
    Bug #701644 "Error: /unregistered in --.pdfexectoken--"
    
    The problem is caused by the insanely complicated (and inefficient)
    way the file is constructed. We have a SMask in a Group, which is
    enclosed within another Group.
    
    When we call start a transparency mask we call pdf_prepare_drawing()
    which calls pdf_update_alpha(). Crucially this is called after we have
    entered a substream for an enclosing Group, but it does not begin a
    new substream.
    
    However, pdf_update_alpha() assumes that if the smask_id has changed
    then a new viewer state has been saved, and the first thing it does
    is restore that state. If no such state has been saved (as here) then
    the code to restore the viewer state sees this as an error (which it is)
    
    We fix this by checking to see if a viewer state has been pushed before
    trying to restore to it.

diff --git a/devices/vector/gdevpdfg.c b/devices/vector/gdevpdfg.c
index 0050aba..665890d 100644
--- a/devices/vector/gdevpdfg.c
+++ b/devices/vector/gdevpdfg.c
@@ -2882,9 +2882,11 @@ pdf_update_alpha(gx_device_pdf *pdev, const gs_gstate *pgs,
             code = pdf_open_contents(pdev, PDF_IN_STREAM);
             if (code < 0)
                 return code;
-            code = pdf_restore_viewer_state(pdev, pdev->strm);
-            if (code < 0)
-                return code;
+            if (pdev->vgstack_depth > pdev->vgstack_bottom) {
+                code = pdf_restore_viewer_state(pdev, pdev->strm);
+                if (code < 0)
+                    return code;
+            }
         }
         else{
             gs_sprintf(buf, "%ld 0 R", pgs->soft_mask_id);


Summary of changes:
 devices/vector/gdevpdfg.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)