summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-01-06 13:46:53 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-01-06 13:52:34 +0000
commit600f22fa3e718c36f3d8f47710df1dbbe0d0c4c2 (patch)
tree7557bfff453c3cf76c31851df177ce6ec8e7c328 /vcl
parent2574757cf026cee4d45195a2f37ecde566411654 (diff)
use same logic in both Creates
Change-Id: I49dab360c5f93e40f5a6e91fbe721935d795472c
Diffstat (limited to 'vcl')
-rw-r--r--vcl/headless/svpbmp.cxx12
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);
}