[Libreoffice-commits] core.git: unotools/source

Noel Grandin noel at peralex.com
Fri Nov 20 01:24:45 PST 2015


 unotools/source/config/fontcfg.cxx |   29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

New commits:
commit 9c5060a6f9c8e94965178dc44bae6ce744d1eb7c
Author: Noel Grandin <noel at peralex.com>
Date:   Fri Nov 20 09:54:21 2015 +0200

    attempt to fix tdf#95935 - CRASH on startup in o3tl vcl code
    
    I suspect that the problem is the shift and that converting it
      "1UL <<"
    will fix it
    
    Change-Id: I4808b833453a544aeb732192758d323f358c3ab0

diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx
index 0409768..d343450 100644
--- a/unotools/source/config/fontcfg.cxx
+++ b/unotools/source/config/fontcfg.cxx
@@ -988,28 +988,27 @@ FontWidth FontSubstConfiguration::getSubstWidth( const css::uno::Reference< XNam
 ImplFontAttrs FontSubstConfiguration::getSubstType( const css::uno::Reference< XNameAccess >& rFont,
                                                     const OUString& rType ) const
 {
-    unsigned long type = 0;
+    sal_uLong type = 0;
     try
     {
         Any aAny = rFont->getByName( rType );
-        if( aAny.getValueTypeClass() == TypeClass_STRING )
+        if( aAny.getValueTypeClass() != TypeClass_STRING )
+            return ImplFontAttrs::None;
+        const OUString* pLine = static_cast<const OUString*>(aAny.getValue());
+        if( pLine->isEmpty() )
+            return ImplFontAttrs::None;
+        sal_Int32 nIndex = 0;
+        while( nIndex != -1 )
         {
-            const OUString* pLine = static_cast<const OUString*>(aAny.getValue());
-            if( !pLine->isEmpty() )
-            {
-                sal_Int32 nIndex = 0;
-                while( nIndex != -1 )
+            OUString aToken( pLine->getToken( 0, ',', nIndex ) );
+            for( int k = 0; k < 32; k++ )
+                if( aToken.equalsIgnoreAsciiCaseAscii( pAttribNames[k] ) )
                 {
-                    OUString aToken( pLine->getToken( 0, ',', nIndex ) );
-                    for( int k = 0; k < 32; k++ )
-                        if( aToken.equalsIgnoreAsciiCaseAscii( pAttribNames[k] ) )
-                        {
-                            type |= 1 << k;
-                            break;
-                        }
+                    type |= 1UL << k;
+                    break;
                 }
-            }
         }
+        assert(((type & ~o3tl::typed_flags<ImplFontAttrs>::mask) == 0) && "invalid font attributes");
     }
     catch (const NoSuchElementException&)
     {


More information about the Libreoffice-commits mailing list