diff options
author | Matúš Kukan <matus.kukan@gmail.com> | 2016-01-11 21:32:55 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2016-01-18 22:53:28 +0100 |
commit | fa7aaf7103f7e39600e936da052d1193a125b92d (patch) | |
tree | e3545d830e30f8ae2c19232ae3f929f12cbcb7e9 /vcl | |
parent | a88e5d59fdf610a07635ca803e2d7193e34eb549 (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>
(cherry picked from commit 39f0277ba71c8f3834579003c046d12fa4650e8f)
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/filter/jpeg/JpegWriter.cxx | 39 |
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 ) |