summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@gmail.com>2016-01-11 21:32:55 +0100
committerDavid Tardon <dtardon@redhat.com>2016-01-12 08:01:56 +0000
commit39f0277ba71c8f3834579003c046d12fa4650e8f (patch)
tree77e6aee458963d968a10dbc3ad39d488300c90ec
parent9059f747c50eaf99a3c065f90b598208edbcb86b (diff)
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@libreoffice.org> Reviewed-by: David Tardon <dtardon@redhat.com>
-rw-r--r--vcl/source/filter/jpeg/JpegWriter.cxx39
1 files changed, 18 insertions, 21 deletions
diff --git a/vcl/source/filter/jpeg/JpegWriter.cxx b/vcl/source/filter/jpeg/JpegWriter.cxx
index fe03540519a5..28143ac71148 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 )