summaryrefslogtreecommitdiffstats
path: root/core/image.cpp
diff options
context:
space:
mode:
authorRafał Mikrut <mikrutrafal54@gmail.com>2019-10-28 08:07:29 +0100
committerRafał Mikrut <mikrutrafal54@gmail.com>2019-10-28 08:07:29 +0100
commite53e1c566ac9e2e9b829f1cdbfd5d27537053cd1 (patch)
tree76cbb7b71e5da369511c6803926e33cbec858715 /core/image.cpp
parent4ecc30cc5ed04c770efd79c2c9f2b1dc9ae0af39 (diff)
downloadredot-engine-e53e1c566ac9e2e9b829f1cdbfd5d27537053cd1.tar.gz
Fix some crashes and using null pointers
Diffstat (limited to 'core/image.cpp')
-rw-r--r--core/image.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/image.cpp b/core/image.cpp
index e0b0a1f8be..5e4e0c0d0c 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -885,8 +885,8 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
bool mipmap_aware = p_interpolation == INTERPOLATE_TRILINEAR /* || p_interpolation == INTERPOLATE_TRICUBIC */;
- ERR_FAIL_COND_MSG(p_width <= 0, "Image width cannot be greater than 0.");
- ERR_FAIL_COND_MSG(p_height <= 0, "Image height cannot be greater than 0.");
+ ERR_FAIL_COND_MSG(p_width <= 0, "Image width must be greater than 0.");
+ ERR_FAIL_COND_MSG(p_height <= 0, "Image height must be greater than 0.");
ERR_FAIL_COND_MSG(p_width > MAX_WIDTH, "Image width cannot be greater than " + itos(MAX_WIDTH) + ".");
ERR_FAIL_COND_MSG(p_height > MAX_HEIGHT, "Image height cannot be greater than " + itos(MAX_HEIGHT) + ".");
@@ -1322,6 +1322,8 @@ void Image::expand_x2_hq2x() {
PoolVector<uint8_t>::Read r = data.read();
PoolVector<uint8_t>::Write w = dest.write();
+ ERR_FAIL_COND(!r.ptr());
+
hq2x_resize((const uint32_t *)r.ptr(), width, height, (uint32_t *)w.ptr());
}
@@ -2895,6 +2897,8 @@ void Image::bumpmap_to_normalmap(float bump_scale) {
PoolVector<uint8_t>::Read rp = data.read();
PoolVector<uint8_t>::Write wp = result_image.write();
+ ERR_FAIL_COND(!rp.ptr());
+
unsigned char *write_ptr = wp.ptr();
float *read_ptr = (float *)rp.ptr();