From 4d48e33345117a4fac639d494958b2d50ef43518 Mon Sep 17 00:00:00 2001 From: Dipal M Zambare Date: Wed, 14 Jul 2021 21:48:35 +0530 Subject: [PATCH] Fixes 50428, added missing checks for image lock (cherry picked from commit b626c57bc786f5f44126e134546fb3d6e4b57dc7) --- core/image.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/image.cpp b/core/image.cpp index 15ae7db3997..7c5ad5e8194 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1104,7 +1104,7 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) { void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) { ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot crop in compressed or custom image formats."); - + ERR_FAIL_COND_MSG(write_lock.ptr(), "Cannot modify image when it is locked."); ERR_FAIL_COND_MSG(p_x < 0, "Start x position cannot be smaller than 0."); ERR_FAIL_COND_MSG(p_y < 0, "Start y position cannot be smaller than 0."); ERR_FAIL_COND_MSG(p_width <= 0, "Width of image must be greater than 0."); @@ -1351,7 +1351,8 @@ void Image::expand_x2_hq2x() { } void Image::shrink_x2() { - + ERR_FAIL_COND(!_can_modify(format)); + ERR_FAIL_COND_MSG(write_lock.ptr(), "Cannot modify image when it is locked."); ERR_FAIL_COND(data.size() == 0); if (mipmaps) { @@ -1455,6 +1456,8 @@ Error Image::generate_mipmaps(bool p_renormalize) { ERR_FAIL_COND_V_MSG(!_can_modify(format), ERR_UNAVAILABLE, "Cannot generate mipmaps in compressed or custom image formats."); + ERR_FAIL_COND_V_MSG(write_lock.ptr(), ERR_UNAVAILABLE, "Cannot modify image when it is locked."); + ERR_FAIL_COND_V_MSG(format == FORMAT_RGBA4444 || format == FORMAT_RGBA5551, ERR_UNAVAILABLE, "Cannot generate mipmaps in custom image formats."); ERR_FAIL_COND_V_MSG(width == 0 || height == 0, ERR_UNCONFIGURED, "Cannot generate mipmaps with width or height equal to 0."); @@ -3020,6 +3023,8 @@ void Image::premultiply_alpha() { } void Image::fix_alpha_edges() { + ERR_FAIL_COND(!_can_modify(format)); + ERR_FAIL_COND_MSG(write_lock.ptr(), "Cannot modify image when it is locked."); if (data.size() == 0) return;