diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2020-12-18 11:59:25 +0100 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-18 21:20:03 +0100 |
commit | 29c5b99832d731071dd201e88d6631c805efe91a (patch) | |
tree | e72bbe5ad470a9cd665c8cb2277ba359d4a833c4 | |
parent | 94e8de1652370ec7d3a09a76b082ba7c77f1b278 (diff) |
fix incorrect array access after a removed enum (tdf#138973)
c521e614359d236405754134a54e8a05bdb1c44c removed some enum values
but didn't remove them from the conversion array.
Change-Id: Idf4837c5929feefb11b400fcd1036370534ed26a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107961
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | vcl/inc/salbmp.hxx | 3 | ||||
-rw-r--r-- | vcl/source/bitmap/salbmp.cxx | 5 |
2 files changed, 5 insertions, 3 deletions
diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx index 943f9d6b2986..adbf70e5c17f 100644 --- a/vcl/inc/salbmp.hxx +++ b/vcl/inc/salbmp.hxx @@ -121,7 +121,8 @@ protected: { A8, RGBA, - BGRA + BGRA, + LAST = BGRA }; static std::unique_ptr< sal_uInt8[] > convertDataBitCount( const sal_uInt8* src, int width, int height, int bitCount, int bytesPerRow, const BitmapPalette& palette, diff --git a/vcl/source/bitmap/salbmp.cxx b/vcl/source/bitmap/salbmp.cxx index 880be0bb437b..7159ac3d5a6b 100644 --- a/vcl/source/bitmap/salbmp.cxx +++ b/vcl/source/bitmap/salbmp.cxx @@ -18,6 +18,7 @@ */ #include <salbmp.hxx> +#include <o3tl/enumarray.hxx> static BitmapChecksum scanlineChecksum(BitmapChecksum nCrc, const sal_uInt8* bits, int lineBitsCount, sal_uInt8 extraBitsMask) { @@ -264,8 +265,8 @@ std::unique_ptr< sal_uInt8[] > SalBitmap::convertDataBitCount( const sal_uInt8* int width, int height, int bitCount, int bytesPerRow, const BitmapPalette& palette, BitConvert type ) { assert( bitCount == 1 || bitCount == 4 || bitCount == 8 ); - static const int bpp[] = { 1, 3, 3, 4, 4 }; - std::unique_ptr< sal_uInt8[] > data( new sal_uInt8[width * height * bpp[ static_cast<int>(type) ]] ); + static const o3tl::enumarray<BitConvert, int> bpp = { 1, 4, 4 }; + std::unique_ptr< sal_uInt8[] > data( new sal_uInt8[width * height * bpp[ type ]] ); if(type == BitConvert::A8 && bitCount == 8 && palette.IsGreyPalette8Bit()) { // no actual data conversion |