summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-03-06 17:48:17 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-03-06 20:32:35 +0100
commitf9b8b666cb28f5b3947d3b4966b4479821dd441f (patch)
treef6f878fd77e0db98e81c485e456cce6c11673b2b /vcl
parent94960bb3357bc443453e4cea2329f34cc7e80196 (diff)
ofz#45230 avoid OOM
Change-Id: Ia209809ddb7713d906fd481384dd463eba6dee57 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131082 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/metaact.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx
index 25d51f276056..abc4495e2b08 100644
--- a/vcl/source/gdi/metaact.cxx
+++ b/vcl/source/gdi/metaact.cxx
@@ -30,6 +30,7 @@
#include <vcl/outdev.hxx>
#include <vcl/metaact.hxx>
#include <vcl/graphictools.hxx>
+#include <unotools/configmgr.hxx>
#include <unotools/fontdefs.hxx>
#include <vcl/TypeSerializer.hxx>
@@ -950,6 +951,27 @@ MetaBmpExScaleAction::MetaBmpExScaleAction( const Point& rPt, const Size& rSz,
void MetaBmpExScaleAction::Execute( OutputDevice* pOut )
{
+ if (utl::ConfigManager::IsFuzzing())
+ {
+ constexpr int nMaxScaleWhenFuzzing = 4096;
+
+ auto nSourceHeight = maBmpEx.GetSizePixel().Height();
+ auto nDestHeight = maSz.Height();
+ if (nSourceHeight && nDestHeight > nSourceHeight && nDestHeight / nSourceHeight > nMaxScaleWhenFuzzing)
+ {
+ SAL_WARN("vcl", "skipping large vertical scaling: " << nSourceHeight << " to " << nDestHeight);
+ return;
+ }
+
+ auto nSourceWidth = maBmpEx.GetSizePixel().Width();
+ auto nDestWidth = maSz.Width();
+ if (nSourceWidth && nDestWidth > nSourceWidth && nDestWidth / nSourceWidth > nMaxScaleWhenFuzzing)
+ {
+ SAL_WARN("vcl", "skipping large horizontal scaling: " << nSourceWidth << " to " << nDestWidth);
+ return;
+ }
+ }
+
pOut->DrawBitmapEx( maPt, maSz, maBmpEx );
}