external/afdko/UnpackedTarball_afdko.mk |    4 ++
 external/afdko/mergeFonts_crash.patch   |   31 +++++++++++++++++
 svx/source/svdraw/svdpdf.cxx            |   56 ++++++++++++++++----------------
 3 files changed, 64 insertions(+), 27 deletions(-)

New commits:
commit 92eebd7c2a944afe63cddbf7b54cafd1cdad4ccd
Author:     Caolán McNamara <[email protected]>
AuthorDate: Tue Sep 30 10:27:59 2025 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Tue Oct 14 20:51:22 2025 +0200

    fix a crash with all whitespace value content
    
    Change-Id: Ic46eebd10461935a1006f010dbb78dd68f448ddc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191675
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit 446322ae5a99473ed88b518f0060cb7ecc004237)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192346
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/external/afdko/UnpackedTarball_afdko.mk 
b/external/afdko/UnpackedTarball_afdko.mk
index 1c23879dcc5f..fc13da9d6b4d 100644
--- a/external/afdko/UnpackedTarball_afdko.mk
+++ b/external/afdko/UnpackedTarball_afdko.mk
@@ -17,6 +17,9 @@ $(eval $(call gb_UnpackedTarball_set_pre_action,afdko,\
 
 $(eval $(call gb_UnpackedTarball_set_patchlevel,afdko,1))
 
+# mergeFonts_crash.patch upstream attempt as:
+# https://github.com/adobe-type-tools/afdko/pull/1806
+
 $(eval $(call gb_UnpackedTarball_add_patches,afdko, \
     external/afdko/extern_tx.patch \
     external/afdko/extern_tx_shared.patch \
@@ -24,6 +27,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,afdko, \
     external/afdko/extern_makeotf.patch \
     external/afdko/warnings.patch \
     external/afdko/antlr4-chrono.patch \
+    external/afdko/mergeFonts_crash.patch \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/afdko/mergeFonts_crash.patch 
b/external/afdko/mergeFonts_crash.patch
new file mode 100644
index 000000000000..b14ea4e1ee91
--- /dev/null
+++ b/external/afdko/mergeFonts_crash.patch
@@ -0,0 +1,31 @@
+--- afdko/c/mergefonts/source/mergeFonts.c
++++ afdko/c/mergefonts/source/mergeFonts.c
+@@ -1177,21 +1177,21 @@
+     if (end == 0)
+         return;
+ 
+-    while (start < MAX_DICT_ENTRY_LEN) {
+-        if ((str[start] == ' ') || (str[start] == '   ') || (str[start] == 
'(') || (str[start] == ' ') || (str[start] == '
'))
+-            start++;
++    while (end >= 0) {
++        if ((str[end] == ' ') || (str[end] == '       ') || (str[end] == ')') 
|| (str[end] == ' ') || (str[end] == '
'))
++            end--;
+         else
+             break;
+     }
++    str[end + 1] = 0;
+ 
+-    while (end >= 0) {
+-        if ((str[end] == ' ') || (str[end] == '       ') || (str[end] == ')') 
|| (str[end] == ' ') || (str[end] == '
'))
+-            end--;
++    while (start < MAX_DICT_ENTRY_LEN) {
++        if ((str[start] == ' ') || (str[start] == '   ') || (str[start] == 
'(') || (str[start] == ' ') || (str[start] == '
'))
++            start++;
+         else
+             break;
+     }
+ 
+-    str[end + 1] = 0;
+     if (start > 0)
+         memmove(str, &str[start], (end - start) + 2);
+     if (strlen(str) == 0) {
commit 317d1b179a3ebebba8c67dd81d722dfdd3b7da56
Author:     Caolán McNamara <[email protected]>
AuthorDate: Mon Sep 29 20:48:06 2025 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Tue Oct 14 20:51:08 2025 +0200

    Always create cidFontInfo, we will need it if we need to merge fonts
    
    Change-Id: I8ffc5efe0ade2d46e318df7ea8cc3352d7ad0fa2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191674
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit 8688279b0ec882ee95e7dacbc45a757fe0fe0c6e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192345
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 489e3ce037de..e68482c8d73a 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1057,37 +1057,39 @@ static bool toPfaCID(SubSetInfo& rSubSetInfo, const 
OUString& fileUrl,
     }
     SAL_INFO("sd.filter", "details are: " << version << Notice << FullName << 
FamilyName << Weight
                                           << srcFontType << FontName);
+
+    // Always create cidFontInfo, we will need it if we need to merge fonts
+    OString AdobeCopyright, Trademark;
+    sal_Int32 nSplit = !Notice.isEmpty() ? Notice.lastIndexOf('.', 
Notice.getLength() - 1) : -1;
+    if (nSplit != -1)
+    {
+        AdobeCopyright = Notice.copy(0, nSplit + 1);
+        Trademark = Notice.copy(nSplit + 1);
+    }
+    else
+        AdobeCopyright = Notice;
+    SvFileStream cidFontInfo(cidFontInfoUrl, StreamMode::READWRITE | 
StreamMode::TRUNC);
+    cidFontInfo.WriteLine(Concat2View("FontName        (" + FontName + ")"));
+    cidFontInfo.WriteLine(Concat2View("FullName        (" + FullName + ")"));
+    OString OutputFamilyName = FamilyName;
+    if (!isSimpleFamilyName(Weight))
+        OutputFamilyName = OutputFamilyName + " " + Weight;
+    cidFontInfo.WriteLine(Concat2View("FamilyName      (" + OutputFamilyName + 
")"));
+    cidFontInfo.WriteLine(Concat2View("version         (" + version + ")"));
+    cidFontInfo.WriteLine("Registry    (Adobe)");
+    cidFontInfo.WriteLine("Ordering    (Identity)");
+    cidFontInfo.WriteLine("Supplement  0");
+    cidFontInfo.WriteLine("XUID                [1 11 9273828]");
+    cidFontInfo.WriteLine("FSType              4");
+    cidFontInfo.WriteLine(Concat2View("AdobeCopyright  (" + AdobeCopyright + 
")"));
+    cidFontInfo.WriteLine(Concat2View("Trademark       (" + Trademark + ")"));
+    cidFontInfo.Close();
+
     bNameKeyed = srcFontType.endsWith("(name-keyed)");
 
     if (bNameKeyed)
     {
-        OString AdobeCopyright, Trademark;
-        sal_Int32 nSplit = Notice.lastIndexOf('.', Notice.getLength() - 1);
-        if (nSplit != -1)
-        {
-            AdobeCopyright = Notice.copy(0, nSplit + 1);
-            Trademark = Notice.copy(nSplit + 1);
-        }
-        else
-            AdobeCopyright = Notice;
-        SAL_WARN("sd.filter", "convert to cid keyed");
-        SvFileStream cidFontInfo(cidFontInfoUrl, StreamMode::READWRITE | 
StreamMode::TRUNC);
-        cidFontInfo.WriteLine(Concat2View("FontName    (" + FontName + ")"));
-        cidFontInfo.WriteLine(Concat2View("FullName    (" + FullName + ")"));
-        OString OutputFamilyName = FamilyName;
-        if (!isSimpleFamilyName(Weight))
-            OutputFamilyName = OutputFamilyName + " " + Weight;
-        cidFontInfo.WriteLine(Concat2View("FamilyName  (" + OutputFamilyName + 
")"));
-        cidFontInfo.WriteLine(Concat2View("version             (" + version + 
")"));
-        cidFontInfo.WriteLine("Registry        (Adobe)");
-        cidFontInfo.WriteLine("Ordering        (Identity)");
-        cidFontInfo.WriteLine("Supplement      0");
-        cidFontInfo.WriteLine("XUID            [1 11 9273828]");
-        cidFontInfo.WriteLine("FSType          4");
-        cidFontInfo.WriteLine(Concat2View("AdobeCopyright      (" + 
AdobeCopyright + ")"));
-        cidFontInfo.WriteLine(Concat2View("Trademark   (" + Trademark + ")"));
-        cidFontInfo.Close();
-
+        SAL_INFO("sd.filter", "convert to cid keyed");
         SvFileStream nameToCIDMap(nameToCIDMapUrl, StreamMode::READWRITE | 
StreamMode::TRUNC);
         nameToCIDMap.WriteLine(Concat2View("mergefonts " + FontName + " 0"));
         for (const auto& glyph : glyphIndexToName)

Reply via email to