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

Matúš Kukan matus.kukan at gmail.com
Mon Jan 11 12:41:56 PST 2016


 vcl/source/filter/jpeg/JpegWriter.cxx |   39 +++++++++++++++-------------------
 1 file changed, 18 insertions(+), 21 deletions(-)

New commits:
commit d5dcfe40ff3774d82a7b8f9f3d75b5b3cdac78ba
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Mon Jan 11 21:32:55 2016 +0100

    tdf#94831: Check for null mpReadAccess before first use
    
    There was erroneously added code before check in
    45e8e0fbee40f9a8d91f4c559c8bbb16dd7b3f36.
    
    Change-Id: Ie2e84cfc061097c25e5d799e9c388abd9724bd93

diff --git a/vcl/source/filter/jpeg/JpegWriter.cxx b/vcl/source/filter/jpeg/JpegWriter.cxx
index cb1a67f..38c65a5 100644
--- a/vcl/source/filter/jpeg/JpegWriter.cxx
+++ b/vcl/source/filter/jpeg/JpegWriter.cxx
@@ -199,32 +199,29 @@ bool JPEGWriter::Write( const Graphic& rGraphic )
     }
 
     mpReadAccess = aGraphicBmp.AcquireReadAccess();
+    if( mpReadAccess )
+    {
+        if ( !mbGreys )  // bitmap was not explicitly converted into greyscale,
+        {                // check if source is greyscale only
+            bool bIsGrey = true;
 
-    if ( !mbGreys )  // bitmap was not explicitly converted into greyscale,
-    {                // check if source is greyscale only
-
-        bool bIsGrey = true;
-
-        long nWidth = mpReadAccess->Width();
-        for ( long nY = 0; bIsGrey && ( nY < mpReadAccess->Height() ); nY++ )
-        {
-            BitmapColor aColor;
-            for( long nX = 0L; bIsGrey && ( nX < nWidth ); nX++ )
+            long nWidth = mpReadAccess->Width();
+            for ( long nY = 0; bIsGrey && ( nY < mpReadAccess->Height() ); nY++ )
             {
-                aColor = mpReadAccess->HasPalette() ? mpReadAccess->GetPaletteColor( mpReadAccess->GetPixelIndex( nY, nX ) )
-                                            : mpReadAccess->GetPixel( nY, nX );
-                bIsGrey = ( aColor.GetRed() == aColor.GetGreen() ) && ( aColor.GetRed() == aColor.GetBlue() );
+                BitmapColor aColor;
+                for( long nX = 0L; bIsGrey && ( nX < nWidth ); nX++ )
+                {
+                    aColor = mpReadAccess->HasPalette() ? mpReadAccess->GetPaletteColor( mpReadAccess->GetPixelIndex( nY, nX ) )
+                                                : mpReadAccess->GetPixel( nY, nX );
+                    bIsGrey = ( aColor.GetRed() == aColor.GetGreen() ) && ( aColor.GetRed() == aColor.GetBlue() );
+                }
             }
+            if ( bIsGrey )
+                mbGreys = true;
         }
-        if ( bIsGrey )
-            mbGreys = true;
-    }
+        if( mpExpWasGrey )
+            *mpExpWasGrey = mbGreys;
 
-    if( mpExpWasGrey )
-        *mpExpWasGrey = mbGreys;
-
-    if( mpReadAccess )
-    {
         mbNative = ( mpReadAccess->GetScanlineFormat() == BMP_FORMAT_24BIT_TC_RGB );
 
         if( !mbNative )


More information about the Libreoffice-commits mailing list