sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 1e0670916be8f9d1347b362364d1c49d8fea3492
Author:     Thorsten Behrens <thorsten.behr...@allotropia.de>
AuthorDate: Sat Jan 13 21:40:09 2024 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Jan 15 16:24:05 2024 +0100

    Fix obscure xpdfimport crash on missing fonts
    
    Invert logic, such that the case WMode == 0 and no font set now run
    the former else branch. Happened here for an obscure pdf I was missing
    some fonts for.
    
    Change-Id: I2825c914a04f6a95d459eeeffb8091ed8f1819dc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162029
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    (cherry picked from commit 1637610478c4493c29a29286b66250ef47507681)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162093
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit a2813ce500a408ed0de716972823277c1f9aeab0)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162096
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx 
b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
index 3ad139b65fa3..2517618e1019 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
@@ -956,18 +956,18 @@ void PDFOutDev::drawChar(GfxState *state, double x, 
double y,
 
     double csdx = 0.0;
     double csdy = 0.0;
-    if (state->getFont()->getWMode())
+    if (!state->getFont() || !state->getFont()->getWMode())
     {
-        csdy = state->getCharSpace();
+        csdx = state->getCharSpace();
         if (*u == ' ')
-            csdy += state->getWordSpace();
+            csdx += state->getWordSpace();
+        csdx *= state->getHorizScaling();
     }
     else
     {
-        csdx = state->getCharSpace();
+        csdy = state->getCharSpace();
         if (*u == ' ')
-            csdx += state->getWordSpace();
-        csdx *= state->getHorizScaling();
+            csdy += state->getWordSpace();
     }
 
     double cstdx = 0.0;

Reply via email to