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

Norbert Thiebaud nthiebaud at gmail.com
Fri Jun 28 02:12:09 PDT 2013


 vcl/source/gdi/bitmap3.cxx |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

New commits:
commit 344d80ee1d3829b28c18135ac4f0500d4b69aedd
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Wed Jun 26 03:17:24 2013 -0500

    coverity#1028110 Dereference before null check
    
    Change-Id: Ie5fb6a0ecad185c1849f55111c17692c280d9454
    Reviewed-on: https://gerrit.libreoffice.org/4531
    Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx
index 250f188..8d5e6a4 100644
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap3.cxx
@@ -1297,8 +1297,6 @@ sal_Bool Bitmap::ImplScaleSuper(
     {
         BitmapColor         aCol0, aCol1, aColRes;
         BitmapReadAccess*   pAcc = AcquireReadAccess();
-        long                nW = pAcc->Width() ;
-        long                nH = pAcc->Height() ;
         Bitmap              aOutBmp( Size( nDstW, nDstH ), 24 );
         BitmapWriteAccess*  pWAcc = aOutBmp.AcquireWriteAccess();
         long*               pMapIX = new long[ nDstW ];
@@ -1316,6 +1314,8 @@ sal_Bool Bitmap::ImplScaleSuper(
 
         if( pAcc && pWAcc )
         {
+            long                nW = pAcc->Width() ;
+            long                nH = pAcc->Height() ;
             const double    fRevScaleX = ( nDstW > 1L ) ? ( (double) ( nW - 1 ) / ( nDstW - 1 ) ) : 0.0;
             const double    fRevScaleY = ( nDstH > 1L ) ? ( (double) ( nH - 1 ) / ( nDstH - 1 ) ) : 0.0;
 
@@ -1488,7 +1488,7 @@ sal_Bool Bitmap::ImplScaleSuper(
                             }
                         }
                     }
-}
+                }
                 else
                 {
                     if( scaleX >= fScaleThresh && scaleY >= fScaleThresh )
@@ -2075,9 +2075,14 @@ sal_Bool Bitmap::ImplScaleSuper(
         delete[] pMapFX;
         delete[] pMapFY;
 
-        ReleaseAccess( pAcc );
-        aOutBmp.ReleaseAccess( pWAcc );
-
+        if(pAcc)
+        {
+            ReleaseAccess( pAcc );
+        }
+        if(pWAcc)
+        {
+            aOutBmp.ReleaseAccess( pWAcc );
+        }
         if( bRet )
         {
             ImplAdaptBitCount(aOutBmp);


More information about the Libreoffice-commits mailing list