2
0
Эх сурвалжийг харах

Fix crash when calling `fill` method on an empty `Image`

(cherry picked from commit adec51cde87d29dd74efb6e5cd0167990de8d569)
Yuri Rubinsky 2 жил өмнө
parent
commit
d3f8563298
1 өөрчлөгдсөн 6 нэмэгдсэн , 0 устгасан
  1. 6 0
      core/image.cpp

+ 6 - 0
core/image.cpp

@@ -2477,6 +2477,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.");
 
 	lock();
@@ -2495,6 +2498,9 @@ void Image::fill(const Color &p_color) {
 }
 
 void Image::fill_rect(const Rect2 &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).clip(p_rect.abs());