From 797315f220f82682748efaf80a29844a93f04f48 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Tue, 22 Sep 2020 13:42:02 +0200 Subject: detect and fail immediately on failed Skia allocations (tdf#135952) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The problem with tdf#135952 is that the PNG export dialog can lead to requesting an absurdly large image, which leads to allocation failures. Some VCL backends such as headless try to cope with this and bail out, but they often crash anyway, since at higher levels of LO code nothing checks for these corner cases anyway. And even if nothing would crash, this can lead to silently losing data. So I've decided to directly detect such cases and fail hard and early. Change-Id: I5277a65c794116206de8280faf22ff897daa2f56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103171 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- vcl/skia/win/gdiimpl.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'vcl/skia/win') diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx index 5c5582b8ffe6..ce67db42914b 100644 --- a/vcl/skia/win/gdiimpl.cxx +++ b/vcl/skia/win/gdiimpl.cxx @@ -313,7 +313,7 @@ sk_sp SkiaCompatibleDC::getAsImage() const SkRect::MakeXYWH(0, 0, maRects.mnSrcWidth, maRects.mnSrcHeight), SkRect::MakeXYWH(0, 0, maRects.mnSrcWidth, maRects.mnSrcHeight), &paint); canvas->restore(); - return surface->makeImageSnapshot(); + return SkiaHelper::makeCheckedImageSnapshot(surface); } sk_sp SkiaCompatibleDC::getAsImageDiff(const SkiaCompatibleDC& white) const @@ -362,7 +362,7 @@ sk_sp SkiaCompatibleDC::getAsImageDiff(const SkiaCompatibleDC& white) c canvas->concat(matrix); canvas->drawBitmap(tmpBitmap, 0, 0, &paint); canvas->restore(); - return surface->makeImageSnapshot(); + return SkiaHelper::makeCheckedImageSnapshot(surface); } SkiaControlsCache::SkiaControlsCache() -- cgit