diff options
Diffstat (limited to 'vcl/headless/svpbmp.cxx')
-rw-r--r-- | vcl/headless/svpbmp.cxx | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index e7d367a75929..d11f3b92adbc 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -121,7 +121,7 @@ BitmapBuffer* ImplCreateDIB( pDIB->maPalette.SetEntryCount( nColors ); } - size_t size = pDIB->mnScanlineSize * pDIB->mnHeight; + const size_t size = pDIB->mnScanlineSize * pDIB->mnHeight; if (size > SAL_MAX_INT32) { delete pDIB; @@ -176,10 +176,18 @@ bool SvpSalBitmap::Create(const SalBitmap& rBmp) { // TODO: reference counting... mpDIB = new BitmapBuffer( *rSalBmp.mpDIB ); + + const size_t size = mpDIB->mnScanlineSize * mpDIB->mnHeight; + if (size > SAL_MAX_INT32) + { + delete mpDIB; + mpDIB = nullptr; + return false; + } + // TODO: get rid of this when BitmapBuffer gets copy constructor try { - size_t size = mpDIB->mnScanlineSize * mpDIB->mnHeight; mpDIB->mpBits = new sal_uInt8[size]; std::memcpy(mpDIB->mpBits, rSalBmp.mpDIB->mpBits, size); } |