diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-01-28 08:14:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-28 08:14:40 +0100 |
commit | 3cfb67e0f7f55f884c01994b7c7f35a5160dfc3e (patch) | |
tree | 08e056ec4823df8c716660b5b755e693547e553f | |
parent | 11b7f9fe0728f8cfe96eadd400913783b1d5e31e (diff) | |
parent | f7d4e6ef6b0e3601cdefebfcc8d0feb29f6892cd (diff) |
Merge pull request #35647 from timothyqiu/image-ops
Fixes invalid writes in Image operations
-rw-r--r-- | core/image.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/image.cpp b/core/image.cpp index 18d0653bae..f43c26ab19 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -421,6 +421,8 @@ void Image::convert(Format p_new_format) { if (p_new_format == format) return; + ERR_FAIL_COND_MSG(write_lock.ptr(), "Cannot convert image when it is locked."); + if (format > FORMAT_RGBE9995 || p_new_format > FORMAT_RGBE9995) { ERR_FAIL_MSG("Cannot convert to <-> from compressed formats. Use compress() and decompress() instead."); @@ -880,8 +882,8 @@ void Image::resize_to_po2(bool p_square) { void Image::resize(int p_width, int p_height, Interpolation p_interpolation) { ERR_FAIL_COND_MSG(data.size() == 0, "Cannot resize image before creating it, use create() or create_from_data() first."); - ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot resize in compressed or custom image formats."); + ERR_FAIL_COND_MSG(write_lock.ptr(), "Cannot resize image when it is locked."); bool mipmap_aware = p_interpolation == INTERPOLATE_TRILINEAR /* || p_interpolation == INTERPOLATE_TRICUBIC */; @@ -2063,6 +2065,7 @@ void Image::blit_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Po ERR_FAIL_COND(dsize == 0); ERR_FAIL_COND(srcdsize == 0); ERR_FAIL_COND(format != p_src->format); + ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot blit_rect in compressed or custom image formats."); Rect2i clipped_src_rect = Rect2i(0, 0, p_src->width, p_src->height).clip(p_src_rect); @@ -2283,6 +2286,7 @@ void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, c } void Image::fill(const Color &c) { + ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot fill in compressed or custom image formats."); lock(); |