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

Caolán McNamara caolanm at redhat.com
Fri Mar 10 11:46:30 UTC 2017


 vcl/source/filter/ixbm/xbmread.cxx |   28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

New commits:
commit d82ea7bdd638fc9fd116238f0eb2179c3cdf9733
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Mar 10 11:45:11 2017 +0000

    ofz#782 oom in xbm
    
    Change-Id: I72e187203843803e7a4e76346d484f22a5cc8823

diff --git a/vcl/source/filter/ixbm/xbmread.cxx b/vcl/source/filter/ixbm/xbmread.cxx
index 4a4c358..38475fd 100644
--- a/vcl/source/filter/ixbm/xbmread.cxx
+++ b/vcl/source/filter/ixbm/xbmread.cxx
@@ -50,7 +50,7 @@ class XBMReader : public GraphicReader
 
     void            InitTable();
     OString         FindTokenLine( SvStream* pInStm, const char* pTok1, const char* pTok2 );
-    long            ParseDefine( const sal_Char* pDefine );
+    int             ParseDefine( const sal_Char* pDefine );
     bool            ParseData( SvStream* pInStm, const OString& aLastLine, XBMFormat eFormat );
 
 public:
@@ -145,9 +145,9 @@ OString XBMReader::FindTokenLine( SvStream* pInStm, const char* pTok1,
     return aRet;
 }
 
-long XBMReader::ParseDefine( const sal_Char* pDefine )
+int XBMReader::ParseDefine( const sal_Char* pDefine )
 {
-    long    nRet = 0;
+    sal_Int32 nRet = 0;
     const char* pTmp = pDefine;
     unsigned char   cTmp;
 
@@ -170,23 +170,11 @@ long XBMReader::ParseDefine( const sal_Char* pDefine )
     if( ( pTmp[0] == '0' ) && ( ( pTmp[1] == 'X' ) || ( pTmp[1] == 'x' ) ) )
     {
         pTmp += 2;
-        cTmp = *pTmp++;
-
-        while ( pHexTable[ cTmp ] != -1 )
-        {
-            nRet = ( nRet << 4 ) + pHexTable[ cTmp ];
-            cTmp = *pTmp++;
-        }
+        nRet = OString(pTmp, strlen(pTmp)).toInt32(16);
     }
-    // read decimal
-    else
+    else // read decimal
     {
-        cTmp = *pTmp++;
-        while( ( cTmp >= '0' ) && ( cTmp <= '9' ) )
-        {
-            nRet = nRet * 10 + ( cTmp - '0' );
-            cTmp = *pTmp++;
-        }
+        nRet = OString(pTmp, strlen(pTmp)).toInt32();
     }
 
     return nRet;
@@ -286,7 +274,7 @@ ReadState XBMReader::ReadXBM( Graphic& rGraphic )
         if ( bStatus )
         {
             int nValue;
-            if ( ( nValue = (int) ParseDefine( aLine.getStr() ) ) > 0 )
+            if ( ( nValue = ParseDefine( aLine.getStr() ) ) > 0 )
             {
                 nWidth = nValue;
                 aLine = FindTokenLine( &rIStm, "#define", "_height" );
@@ -304,7 +292,7 @@ ReadState XBMReader::ReadXBM( Graphic& rGraphic )
 
             if ( bStatus )
             {
-                if ( ( nValue = (int) ParseDefine( aLine.getStr() ) ) > 0 )
+                if ( ( nValue = ParseDefine( aLine.getStr() ) ) > 0 )
                 {
                     nHeight = nValue;
                     aLine = FindTokenLine( &rIStm, "static", "_bits" );


More information about the Libreoffice-commits mailing list