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

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