summaryrefslogtreecommitdiffstats
path: root/source/ap/ghostscript/ghostscript-subclassing-devices-fix-put_image-method.patch
blob: fadb948d57a490124d050532cbe63fbcfcd16e3f (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
From fae21f1668d2b44b18b84cf0923a1d5f3008a696 Mon Sep 17 00:00:00 2001
From: Ken Sharp <ken.sharp@artifex.com>
Date: Tue, 4 Dec 2018 21:31:31 +0000
Subject: subclassing devices - fix put_image method

The subclassing devices need to change the 'memory device' parameter to
be the child device, when its the same as the subclassing device.

Otherwise we end up trying to access the child device's memory pointers
in the subclassing device, which may not contain valid copies of
those pointers.

diff --git a/base/gdevsclass.c b/base/gdevsclass.c
index d9c85d2e4..51092585a 100644
--- a/base/gdevsclass.c
+++ b/base/gdevsclass.c
@@ -797,7 +797,10 @@ int default_subclass_put_image(gx_device *dev, gx_device *mdev, const byte **buf
             int alpha_plane_index, int tag_plane_index)
 {
     if (dev->child)
-        return dev_proc(dev->child, put_image)(dev->child, mdev, buffers, num_chan, x, y, width, height, row_stride, alpha_plane_index, tag_plane_index);
+        if (dev == mdev)
+            return dev_proc(dev->child, put_image)(dev->child, dev->child, buffers, num_chan, x, y, width, height, row_stride, alpha_plane_index, tag_plane_index);
+        else
+            return dev_proc(dev->child, put_image)(dev->child, mdev, buffers, num_chan, x, y, width, height, row_stride, alpha_plane_index, tag_plane_index);
 
     return 0;
 }