mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Prevent upscaled SVG from exceeding Image bounds
Also expose Image MAX_WIDTH and MAX_HEIGHT.
Fixes #24455.
(cherry picked from commit cc0842f9a6)
This commit is contained in:
@@ -110,7 +110,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);
|
||||
|
||||
Reference in New Issue
Block a user