summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-06-22 15:41:11 +0200
committerMichael Stahl <mstahl@redhat.com>2016-06-23 11:39:00 +0200
commitcd292ba17c62a90f3530326f7fc87036da16a353 (patch)
tree390a204bbf0cbd167bf0fd07da1e1479eb1cacd3 /vcl
parented2d342e97e43ff25f450ab6a5752baded6813e4 (diff)
vcl: avoid vcl_filters_test crash with ASAN 32-bit
ASAN usually aborts on operator new[] allocation failure but with allocator_may_return_null=1 in ASAN_OPTIONS it returns null instead; it doesn't throw std::bad_alloc though. Change-Id: I28d67a787e90604c12ad06fd97d265664bd62ef2
Diffstat (limited to 'vcl')
-rw-r--r--vcl/headless/svpbmp.cxx12
1 files changed, 11 insertions, 1 deletions
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index cb8c77126ba8..f5dabae42ae7 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -125,7 +125,17 @@ BitmapBuffer* ImplCreateDIB(
{
size_t size = pDIB->mnScanlineSize * pDIB->mnHeight;
pDIB->mpBits = new sal_uInt8[size];
- std::memset(pDIB->mpBits, 0, size);
+#ifdef __SANITIZE_ADDRESS__
+ if (!pDIB->mpBits)
+ { // can only happen with ASAN allocator_may_return_null=1
+ delete pDIB;
+ pDIB = nullptr;
+ }
+ else
+#endif
+ {
+ std::memset(pDIB->mpBits, 0, size);
+ }
}
catch (const std::bad_alloc&)
{