diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-01-28 16:44:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-28 16:44:13 +0100 |
commit | ac01aef9e3e9839809306efc915f6e4fa4ac303f (patch) | |
tree | aff98a8d89c2507f4efab34fe537a82f986adad7 /modules/svg/image_loader_svg.cpp | |
parent | 89e7c2cb13c6f06eb376aae5e9354f4fabf01f3e (diff) | |
parent | cc0842f9a6b0fda07ca0b8ad483e225b492428c7 (diff) |
Merge pull request #25417 from akien-mga/svg-max-size
Prevent upscaled SVG from exceeding Image bounds
Diffstat (limited to 'modules/svg/image_loader_svg.cpp')
-rw-r--r-- | modules/svg/image_loader_svg.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
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<Image> p_image, const PoolVector<uint8_t float upscale = upsample ? 2.0 : 1.0; int w = (int)(svg_image->width * 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<uint8_t> dst_image; dst_image.resize(w * h * 4); |