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

Caolán McNamara caolanm at redhat.com
Mon Feb 13 14:38:09 UTC 2017


 filter/source/graphicfilter/ipcx/ipcx.cxx |   26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

New commits:
commit 7c9c6a4425b679596acae6f67ee8ac5f3d98bd6e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Feb 13 14:32:30 2017 +0000

    ofz: move size check before bitmap allocation
    
    Change-Id: I09deab103a3bc53277ea3d545b2737438875dfc5

diff --git a/filter/source/graphicfilter/ipcx/ipcx.cxx b/filter/source/graphicfilter/ipcx/ipcx.cxx
index 4bb500d..8ded909 100644
--- a/filter/source/graphicfilter/ipcx/ipcx.cxx
+++ b/filter/source/graphicfilter/ipcx/ipcx.cxx
@@ -90,8 +90,14 @@ bool PCXReader::ReadPCX(Graphic & rGraphic)
 
     ImplReadHeader();
 
+    // sanity check there is enough data before trying allocation
+    if (bStatus && nBytesPerPlaneLin > m_rPCX.remainingSize() / nPlanes)
+    {
+        bStatus = false;
+    }
+
     // Write BMP header and conditionally (maybe invalid for now) color palette:
-    if ( bStatus )
+    if (bStatus)
     {
         aBmp = Bitmap( Size( nWidth, nHeight ), nDestBitsPerPixel );
         Bitmap::ScopedWriteAccess pAcc(aBmp);
@@ -108,6 +114,7 @@ bool PCXReader::ReadPCX(Graphic & rGraphic)
                 pAcc->SetPaletteColor( i, BitmapColor ( pPal[ 0 ], pPal[ 1 ], pPal[ 2 ] ) );
             }
         }
+
         // read bitmap data
         ImplReadBody(pAcc.get());
 
@@ -124,14 +131,8 @@ bool PCXReader::ReadPCX(Graphic & rGraphic)
                 pAcc->SetPaletteColor( i, BitmapColor ( pPal[ 0 ], pPal[ 1 ], pPal[ 2 ] ) );
             }
         }
-    /*
-        // set resolution:
-        if (nResX!=0 && nResY!=0) {
-            MapMode aMapMode(MapUnit::MapInch,Point(0,0),Fraction(1,nResX),Fraction(1,nResY));
-            rBitmap.SetPrefMapMode(aMapMode);
-            rBitmap.SetPrefSize(Size(nWidth,nHeight));
-        }
-    */  if ( bStatus )
+
+        if ( bStatus )
         {
             rGraphic = aBmp;
             return true;
@@ -206,13 +207,6 @@ void PCXReader::ImplReadBody(BitmapWriteAccess * pAcc)
     sal_uLong   nLastPercent = 0;
     sal_uInt8   nDat = 0, nCol = 0;
 
-    //sanity check there is enough data before trying allocation
-    if (nBytesPerPlaneLin > m_rPCX.remainingSize() / nPlanes)
-    {
-        bStatus = false;
-        return;
-    }
-
     for( np = 0; np < nPlanes; np++ )
         pPlane[ np ] = new sal_uInt8[ nBytesPerPlaneLin ];
 


More information about the Libreoffice-commits mailing list