summaryrefslogtreecommitdiff
path: root/modules/noise
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2022-05-01 13:06:44 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2022-05-01 15:53:27 +0800
commit3012b76ec5a1bf26d2df29d67957e7aef2c20660 (patch)
tree5cf2881fded7c9c359d04800a262c529cffce0b5 /modules/noise
parent4a9e8b560a648f4c1746697b348ebbbb89c5bb0a (diff)
Validate image size for Noise get image methods
Diffstat (limited to 'modules/noise')
-rw-r--r--modules/noise/noise.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/noise/noise.cpp b/modules/noise/noise.cpp
index ad3df0a016..d14b63f7c8 100644
--- a/modules/noise/noise.cpp
+++ b/modules/noise/noise.cpp
@@ -31,6 +31,8 @@
#include "noise.h"
Ref<Image> Noise::get_seamless_image(int p_width, int p_height, bool p_invert, bool p_in_3d_space, real_t p_blend_skirt) const {
+ ERR_FAIL_COND_V(p_width <= 0 || p_height <= 0, Ref<Image>());
+
int skirt_width = p_width * p_blend_skirt;
int skirt_height = p_height * p_blend_skirt;
int src_width = p_width + skirt_width;
@@ -55,6 +57,8 @@ uint8_t Noise::_alpha_blend<uint8_t>(uint8_t p_bg, uint8_t p_fg, int p_alpha) co
}
Ref<Image> Noise::get_image(int p_width, int p_height, bool p_invert, bool p_in_3d_space) const {
+ ERR_FAIL_COND_V(p_width <= 0 || p_height <= 0, Ref<Image>());
+
Vector<uint8_t> data;
data.resize(p_width * p_height);