From b5885c43eb479d1ea8beb71aac09b118a08cb855 Mon Sep 17 00:00:00 2001 From: Jerome67000 Date: Sat, 6 Jan 2018 13:10:37 +0100 Subject: Fix crash when using Image.resize() without calling Image.create() first --- core/image.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'core/image.cpp') diff --git a/core/image.cpp b/core/image.cpp index 59d66fd66..41d70e6df 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -447,8 +447,6 @@ void Image::convert(Format p_new_format) { Image new_img(width, height, 0, p_new_format); - //int len=data.size(); - PoolVector::Read r = data.read(); PoolVector::Write w = new_img.data.write(); @@ -696,6 +694,11 @@ void Image::resize_to_po2(bool p_square) { void Image::resize(int p_width, int p_height, Interpolation p_interpolation) { + if (data.size() == 0) { + ERR_EXPLAIN("Cannot resize image before creating it, use create() or create_from_data() first."); + ERR_FAIL(); + } + if (!_can_modify(format)) { ERR_EXPLAIN("Cannot resize in indexed, compressed or custom image formats."); ERR_FAIL(); -- cgit v1.2.3-70-g09d2