diff options
-rw-r--r-- | include/vcl/BitmapTools.hxx | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx index 2ff0f69eea79..941ef8c9c381 100644 --- a/include/vcl/BitmapTools.hxx +++ b/include/vcl/BitmapTools.hxx @@ -24,6 +24,7 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <o3tl/safeint.hxx> #include <array> +#include <limits> namespace vcl { namespace bitmap { @@ -43,6 +44,10 @@ public: mnBitCount(nBitCount) { assert(nBitCount == 24 || nBitCount == 32); + if (rSize.getWidth() > std::numeric_limits<sal_Int32>::max() || rSize.getWidth() < 0) + throw std::bad_alloc(); + if (rSize.getHeight() > std::numeric_limits<sal_Int32>::max() || rSize.getHeight() < 0) + throw std::bad_alloc(); sal_Int32 nRowSize, nDataSize; if (o3tl::checked_multiply<sal_Int32>(rSize.getWidth(), nBitCount/8, nRowSize) || o3tl::checked_multiply<sal_Int32>(nRowSize, rSize.getHeight(), nDataSize) || |