From cc0842f9a6b0fda07ca0b8ad483e225b492428c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 28 Jan 2019 15:33:56 +0100 Subject: Prevent upscaled SVG from exceeding Image bounds Also expose Image MAX_WIDTH and MAX_HEIGHT. Fixes #24455. --- modules/svg/image_loader_svg.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'modules/svg') diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp index 404ca24482..e36844a1bc 100644 --- a/modules/svg/image_loader_svg.cpp +++ b/modules/svg/image_loader_svg.cpp @@ -109,7 +109,12 @@ Error ImageLoaderSVG::_create_image(Ref p_image, const PoolVectorwidth * p_scale * upscale); + ERR_EXPLAIN(vformat("Can't create image from SVG with scale %s, the resulting image size exceeds max width.", rtos(p_scale))); + ERR_FAIL_COND_V(w > Image::MAX_WIDTH, ERR_PARAMETER_RANGE_ERROR); + int h = (int)(svg_image->height * p_scale * upscale); + ERR_EXPLAIN(vformat("Can't create image from SVG with scale %s, the resulting image size exceeds max height.", rtos(p_scale))); + ERR_FAIL_COND_V(h > Image::MAX_HEIGHT, ERR_PARAMETER_RANGE_ERROR); PoolVector dst_image; dst_image.resize(w * h * 4); -- cgit v1.2.3