summaryrefslogtreecommitdiff
path: root/vcl/unx/generic/gdi/salbmp.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/unx/generic/gdi/salbmp.cxx')
-rw-r--r--vcl/unx/generic/gdi/salbmp.cxx17
1 files changed, 16 insertions, 1 deletions
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index 73fc5a424152..00043d5e783e 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -41,6 +41,7 @@
#include <unx/salinst.h>
#include <unx/x11/xlimits.hxx>
+#include <o3tl/safeint.hxx>
#include <opengl/salbmp.hxx>
#include <vcl/opengl/OpenGLHelper.hxx>
@@ -193,7 +194,21 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB(
pDIB->mnWidth = rSize.Width();
pDIB->mnHeight = rSize.Height();
- pDIB->mnScanlineSize = AlignedWidth4Bytes( pDIB->mnWidth * nBitCount );
+ long nScanlineBase;
+ bool bFail = o3tl::checked_multiply<long>(pDIB->mnWidth, nBitCount, nScanlineBase);
+ if (bFail)
+ {
+ SAL_WARN("vcl.gdi", "checked multiply failed");
+ delete pDIB;
+ return nullptr;
+ }
+ pDIB->mnScanlineSize = AlignedWidth4Bytes(nScanlineBase);
+ if (pDIB->mnScanlineSize < nScanlineBase/8)
+ {
+ SAL_WARN("vcl.gdi", "scanline calculation wraparound");
+ delete pDIB;
+ return nullptr;
+ }
pDIB->mnBitCount = nBitCount;
if( nColors )