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

Matúš Kukan matus.kukan at gmail.com
Tue Jan 12 00:02:20 PST 2016


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

New commits:
commit 39f0277ba71c8f3834579003c046d12fa4650e8f
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
    (cherry picked from commit d5dcfe40ff3774d82a7b8f9f3d75b5b3cdac78ba)
    Reviewed-on: https://gerrit.libreoffice.org/21373
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: David Tardon <dtardon at redhat.com>

diff --git a/vcl/source/filter/jpeg/JpegWriter.cxx b/vcl/source/filter/jpeg/JpegWriter.cxx
index fe03540..28143ac 100644
--- a/vcl/source/filter/jpeg/JpegWriter.cxx
+++ b/vcl/source/filter/jpeg/JpegWriter.cxx
@@ -200,32 +200,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