Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates-src > by-pkgid > bc219369320b6b5781eed48254462cef > files > 4

ghostscript-9.25-1.2.mga6.src.rpm

From 1535333e85a2901cc873c2694c5ee8508cffd992 Mon Sep 17 00:00:00 2001
From: Ken Sharp <ken.sharp@artifex.com>
Date: Mon, 17 Sep 2018 12:14:36 +0100
Subject: [PATCH] Bug 699777 " -dFILTERIMAGE often loses text"

The pdfwrite device's implementation of transparency relies upon the
image for a Softmask being run, and pushing a clip, which increments the
viewer state. However if we have -dFILTERIMAGE in place, then we won't
do this (its in the pdfwrite implementation of begin_typed_image).

When we close the transparency mask, this then leads to the viewer state
stack being out by one.

There's no easy way to address this, so when we go to restore the viewer
state, if it would fall off the bottom then check to see if FILTERIMAGE
is true. If it is, then just don't return an error.

This is a rare condition, it relies upon the transparency being nested
quite deeply in groups (in this case the SoftMask is nested about four
layers deep in spurious transparency).
---
 devices/vector/gdevpdfg.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/devices/vector/gdevpdfg.c b/devices/vector/gdevpdfg.c
index bd9a274..5ecd922 100644
--- a/devices/vector/gdevpdfg.c
+++ b/devices/vector/gdevpdfg.c
@@ -159,10 +159,15 @@ pdf_load_viewer_state(gx_device_pdf *pdev, pdf_viewer_state *s)
 /* Restore the viewer's graphic state. */
 int
 pdf_restore_viewer_state(gx_device_pdf *pdev, stream *s)
-{   const int i = --pdev->vgstack_depth;
+{
+    const int i = --pdev->vgstack_depth;
 
-    if (i < pdev->vgstack_bottom || i < 0)
-        return_error(gs_error_unregistered); /* Must not happen. */
+    if (i < pdev->vgstack_bottom || i < 0) {
+        if ((pdev->ObjectFilter & FILTERIMAGE) == 0)
+            return_error(gs_error_unregistered); /* Must not happen. */
+        else
+            return 0;
+    }
     if (s)
         stream_puts(s, "Q\n");
     pdf_load_viewer_state(pdev, pdev->vgstack + i);
-- 
2.9.1