summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-08-29 16:58:11 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2021-11-17 19:19:34 +0100
commit26bc198d9a2f00a82df3d4074d3502224953ef9b (patch)
tree3c832aa321d0a659a781338df7df8543d5cfa97a /include
parentcb05fd09ddaf3eac850c1c1f967a89024d2294e3 (diff)
ofz#37796 limit to numeric_limits<int>::max
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121230 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 72da4c623baf60eb2b7073697cd36ffb3022847d) Change-Id: I6e09226fad1e566ba2758d0084042b603b84d221
Diffstat (limited to 'include')
-rw-r--r--include/vcl/BitmapTools.hxx5
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) ||