Blame SOURCES/ghostscript-9.54.0-Deal-with-different-VM-modes-during-CIDFont-loading.patch

937b19
From 0b74b65ecc0f36d40b8d04a7fa1fa8b5f9d2b3ff Mon Sep 17 00:00:00 2001
937b19
From: Chris Liddell <chris.liddell@artifex.com>
937b19
Date: Thu, 13 Oct 2022 14:55:28 +0100
937b19
Subject: [PATCH] Deal with different VM modes during CIDFont loading
937b19
937b19
To help differentiate between a substituted CIDFont and an embedded one, a
937b19
change was made to store the file path in the CIDFont dictionary. That change
937b19
failed to account for the possibility that the file object and the CIDFont
937b19
dictionary may not be in compatible VM modes.
937b19
937b19
This adds code to ensure that the string holding the path is in a suitable VM
937b19
mode to be stored into the dictionary.
937b19
937b19
Reported by Richard Lescak <rlescak@redhat.com>
937b19
---
937b19
 Resource/Init/gs_cidfn.ps | 23 +++++++++++++++++++----
937b19
 1 file changed, 19 insertions(+), 4 deletions(-)
937b19
937b19
diff --git a/Resource/Init/gs_cidfn.ps b/Resource/Init/gs_cidfn.ps
937b19
index 870a2e11c..fa050ed7a 100644
937b19
--- a/Resource/Init/gs_cidfn.ps
937b19
+++ b/Resource/Init/gs_cidfn.ps
937b19
@@ -1,4 +1,4 @@
937b19
-% Copyright (C) 2001-2021 Artifex Software, Inc.
937b19
+% Copyright (C) 2001-2022 Artifex Software, Inc.
937b19
 % All Rights Reserved.
937b19
 %
937b19
 % This software is provided AS-IS with no warranty, either express or
937b19
@@ -36,6 +36,17 @@
937b19
 
937b19
 30 dict begin
937b19
 
937b19
+/.gcompatstringcopy % <string> <global> .gcompatstringcopy <string>
937b19
+{
937b19
+   dup 2 index gcheck eq
937b19
+   { pop }
937b19
+   {
937b19
+       currentglobal 3 1 roll setglobal
937b19
+       dup length string copy
937b19
+       exch setglobal
937b19
+   } ifelse
937b19
+} bind def
937b19
+
937b19
 % The key in .cidfonttypes is the CIDFontType value;
937b19
 % the value is a procedure that takes a font name and the CIDFont dictionary
937b19
 % and replaces the latter with a real font.
937b19
@@ -58,7 +69,7 @@ dup 0 {
937b19
     end
937b19
   } if
937b19
   1 index exch .buildfont9
937b19
-  .currentresourcefile dup type /filetype eq { //.filename {1 index exch /ResourcePath exch put} if }{ pop} ifelse
937b19
+  .currentresourcefile dup type /filetype eq { //.filename {1 index gcheck //.gcompatstringcopy exec 1 index exch /ResourcePath exch put} if }{ pop} ifelse
937b19
   exch pop
937b19
 } put % Don't bind it here, because gs_fapi.ps redefines .buildfont9
937b19
 
937b19
@@ -138,10 +149,11 @@ dup 0 {
937b19
 
937b19
 % ------ CIDFontType 1 (FontType 10) ------ %
937b19
 
937b19
+
937b19
 dup 1 {
937b19
   10 //.checkfonttype exec pop
937b19
   1 index exch .buildfont10
937b19
-  .currentresourcefile dup type /filetype eq { //.filename {1 index exch /ResourcePath exch put} if }{ pop} ifelse
937b19
+  .currentresourcefile dup type /filetype eq { //.filename {1 index gcheck //.gcompatstringcopy exec 1 index exch /ResourcePath exch put} if }{ pop} ifelse
937b19
   exch pop
937b19
 } put % Don't bind it here because gs_fapi.ps redefines .buildfont10
937b19
 
937b19
@@ -150,12 +162,15 @@ dup 1 {
937b19
 dup 2 {
937b19
   11 //.checkfonttype exec pop
937b19
   1 index exch .buildfont11
937b19
-  .currentresourcefile dup type /filetype eq { //.filename {1 index exch /ResourcePath exch put} if }{ pop} ifelse
937b19
+  .currentresourcefile dup type /filetype eq { //.filename {1 index gcheck //.gcompatstringcopy exec 1 index exch /ResourcePath exch put} if }{ pop} ifelse
937b19
   exch pop
937b19
 } put % Don't bind it here because gs_fapi.ps redefines .buildfont11
937b19
 
937b19
+currentdict /.gcompatstringcopy .undef
937b19
+
937b19
 pop		% .cidfonttypes
937b19
 
937b19
+
937b19
 % ---------------- Reading CIDFontType 0 files ---------------- %
937b19
 
937b19
 /StartData {		% <(Binary)|(Hex)> <datalength> StartData -
937b19
-- 
937b19
2.37.3
937b19