vcl/source/gdi/metaact.cxx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
New commits: commit f9b8b666cb28f5b3947d3b4966b4479821dd441f Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Sun Mar 6 17:48:17 2022 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sun Mar 6 20:32:35 2022 +0100 ofz#45230 avoid OOM Change-Id: Ia209809ddb7713d906fd481384dd463eba6dee57 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131082 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> 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 ); }