[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - vcl/source

Caolán McNamara caolanm at redhat.com
Fri Feb 10 12:51:56 UTC 2017


 vcl/source/gdi/svmconverter.cxx |   49 ++++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 19 deletions(-)

New commits:
commit 43f36b8b10a36169fedff568c75c14e82703b979
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Feb 9 09:21:39 2017 +0000

    Resolves: ofz#576 unexpected exception with invalid fraction
    
    (cherry picked from commit cff6cdb2ee37e836b9bab39500d24fcedc360121)
    
    Change-Id: I1d653775e88e9fa2ba7b62fce39d52fc21ffe363
    Reviewed-on: https://gerrit.libreoffice.org/34070
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/vcl/source/gdi/svmconverter.cxx b/vcl/source/gdi/svmconverter.cxx
index 12dec2d..32648f7 100644
--- a/vcl/source/gdi/svmconverter.cxx
+++ b/vcl/source/gdi/svmconverter.cxx
@@ -129,19 +129,26 @@ void ImplWriteColor( SvStream& rOStm, const Color& rColor )
     rOStm.WriteInt16( nVal );
 }
 
-void ImplReadMapMode( SvStream& rIStm, MapMode& rMapMode )
+bool ImplReadMapMode(SvStream& rIStm, MapMode& rMapMode)
 {
-    Point   aOrg;
-    sal_Int32   nXNum;
-    sal_Int32   nXDenom;
-    sal_Int32   nYNum;
-    sal_Int32   nYDenom;
-    sal_Int16   nUnit;
-
-    rIStm.ReadInt16( nUnit );
-    ReadPair( rIStm, aOrg );
-    rIStm.ReadInt32( nXNum ).ReadInt32( nXDenom ).ReadInt32( nYNum ).ReadInt32( nYDenom );
+    sal_Int16 nUnit(0);
+    rIStm.ReadInt16(nUnit);
+
+    Point aOrg;
+    ReadPair(rIStm, aOrg);
+
+    sal_Int32 nXNum(0), nXDenom(0), nYNum(0), nYDenom(0);
+    rIStm.ReadInt32(nXNum).ReadInt32(nXDenom).ReadInt32(nYNum).ReadInt32(nYDenom);
+
+    if (!rIStm.good() || nXDenom == 0 || nYDenom == 0)
+    {
+        SAL_WARN("vcl.gdi", "Parsing error: invalid mapmode fraction");
+        return false;
+    }
+
     rMapMode = MapMode( (MapUnit) nUnit, aOrg, Fraction( nXNum, nXDenom ), Fraction( nYNum, nYDenom ) );
+
+    return true;
 }
 
 void ImplWriteMapMode( SvStream& rOStm, const MapMode& rMapMode )
@@ -506,7 +513,6 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
     bool                bFatLine = false;
 
     // TODO: fix reindentation below if you can accept being blamed by the SCM
-        MapMode     aMapMode;
         tools::Polygon     aActionPoly;
         Rectangle   aRect;
         Point       aPt, aPt1;
@@ -516,7 +522,12 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
         sal_uInt32  nUnicodeCommentStreamPos = 0;
         sal_Int32       nUnicodeCommentActionNumber = 0;
 
-        ImplReadMapMode( rIStm, aMapMode );             // MapMode
+        rMtf.SetPrefSize( aPrefSz );
+
+        MapMode aMapMode;
+        if (ImplReadMapMode(rIStm, aMapMode))           // MapMode
+            rMtf.SetPrefMapMode(aMapMode);
+
         sal_Int32 nActions(0);
         rIStm.ReadInt32( nActions );                    // Action count
         if (nActions < 0)
@@ -533,8 +544,6 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
             nActions = nMaxPossibleActions;
         }
 
-        rMtf.SetPrefSize( aPrefSz );
-        rMtf.SetPrefMapMode( aMapMode );
         size_t nLastPolygonAction(0);
 
         for (sal_Int32 i = 0; i < nActions && rIStm.good(); ++i)
@@ -1059,11 +1068,13 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
 
                 case GDI_MAPMODE_ACTION:
                 {
-                    ImplReadMapMode( rIStm, aMapMode );
-                    rMtf.AddAction( new MetaMapModeAction( aMapMode ) );
+                    if (ImplReadMapMode(rIStm, aMapMode))
+                    {
+                        rMtf.AddAction(new MetaMapModeAction(aMapMode));
 
-                    // #106172# Track font relevant data in shadow VDev
-                    aFontVDev->SetMapMode( aMapMode );
+                        // #106172# Track font relevant data in shadow VDev
+                        aFontVDev->SetMapMode(aMapMode);
+                    }
                 }
                 break;
 


More information about the Libreoffice-commits mailing list