diff options
author | Yuri Rubinsky <chaosus89@gmail.com> | 2022-10-24 11:28:10 +0300 |
---|---|---|
committer | Yuri Rubinsky <chaosus89@gmail.com> | 2022-10-24 11:28:10 +0300 |
commit | adec51cde87d29dd74efb6e5cd0167990de8d569 (patch) | |
tree | b4a8b2e513657fda377b33721a537f03c1a0e63e /core/io | |
parent | 040f49ed6e71a6e7f23d763c4b56095cbf319ef7 (diff) |
Fix crash when calling `fill` method on an empty `Image`
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/image.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/core/io/image.cpp b/core/io/image.cpp index 3450eb7abd..16dd66fc98 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -2862,6 +2862,9 @@ void Image::_repeat_pixel_over_subsequent_memory(uint8_t *p_pixel, int p_pixel_s } void Image::fill(const Color &p_color) { + if (data.size() == 0) { + return; + } ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot fill in compressed or custom image formats."); uint8_t *dst_data_ptr = data.ptrw(); @@ -2875,6 +2878,9 @@ void Image::fill(const Color &p_color) { } void Image::fill_rect(const Rect2i &p_rect, const Color &p_color) { + if (data.size() == 0) { + return; + } ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot fill rect in compressed or custom image formats."); Rect2i r = Rect2i(0, 0, width, height).intersection(p_rect.abs()); |