Bug 1466613 - Prevent creation of DynamicImage instances that are excessively large. r=mstange

Differential Revision: https://phabricator.services.mozilla.com/D11528

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kartikaya Gupta 2018-11-13 10:39:27 +00:00
Родитель 17eea57296
Коммит 76cb4247d3
1 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -732,8 +732,13 @@ nsImageRenderer::DrawableForElement(const nsRect& aImageRect,
nsRect destRect = aImageRect - aImageRect.TopLeft(); nsRect destRect = aImageRect - aImageRect.TopLeft();
nsIntSize roundedOut = destRect.ToOutsidePixels(appUnitsPerDevPixel).Size(); nsIntSize roundedOut = destRect.ToOutsidePixels(appUnitsPerDevPixel).Size();
IntSize imageSize(roundedOut.width, roundedOut.height); IntSize imageSize(roundedOut.width, roundedOut.height);
RefPtr<gfxDrawable> drawable =
nsSVGIntegrationUtils::DrawableFromPaintServer( RefPtr<gfxDrawable> drawable;
SurfaceFormat format = aContext.GetDrawTarget()->GetFormat();
// Don't allow creating images that are too big
if (aContext.GetDrawTarget()->CanCreateSimilarDrawTarget(imageSize, format)) {
drawable = nsSVGIntegrationUtils::DrawableFromPaintServer(
mPaintServerFrame, mPaintServerFrame,
mForFrame, mForFrame,
mSize, mSize,
@ -741,6 +746,7 @@ nsImageRenderer::DrawableForElement(const nsRect& aImageRect,
aContext.GetDrawTarget(), aContext.GetDrawTarget(),
aContext.CurrentMatrixDouble(), aContext.CurrentMatrixDouble(),
nsSVGIntegrationUtils::FLAG_SYNC_DECODE_IMAGES); nsSVGIntegrationUtils::FLAG_SYNC_DECODE_IMAGES);
}
return drawable.forget(); return drawable.forget();
} }