Fix some crashes and using null pointers

This commit is contained in:
Rafał Mikrut 2019-10-28 08:07:29 +01:00
parent 4ecc30cc5e
commit e53e1c566a
15 changed files with 37 additions and 19 deletions

View file

@ -885,8 +885,8 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
bool mipmap_aware = p_interpolation == INTERPOLATE_TRILINEAR /* || p_interpolation == INTERPOLATE_TRICUBIC */;
ERR_FAIL_COND_MSG(p_width <= 0, "Image width cannot be greater than 0.");
ERR_FAIL_COND_MSG(p_height <= 0, "Image height cannot be greater than 0.");
ERR_FAIL_COND_MSG(p_width <= 0, "Image width must be greater than 0.");
ERR_FAIL_COND_MSG(p_height <= 0, "Image height must be greater than 0.");
ERR_FAIL_COND_MSG(p_width > MAX_WIDTH, "Image width cannot be greater than " + itos(MAX_WIDTH) + ".");
ERR_FAIL_COND_MSG(p_height > MAX_HEIGHT, "Image height cannot be greater than " + itos(MAX_HEIGHT) + ".");
@ -1322,6 +1322,8 @@ void Image::expand_x2_hq2x() {
PoolVector<uint8_t>::Read r = data.read();
PoolVector<uint8_t>::Write w = dest.write();
ERR_FAIL_COND(!r.ptr());
hq2x_resize((const uint32_t *)r.ptr(), width, height, (uint32_t *)w.ptr());
}
@ -2895,6 +2897,8 @@ void Image::bumpmap_to_normalmap(float bump_scale) {
PoolVector<uint8_t>::Read rp = data.read();
PoolVector<uint8_t>::Write wp = result_image.write();
ERR_FAIL_COND(!rp.ptr());
unsigned char *write_ptr = wp.ptr();
float *read_ptr = (float *)rp.ptr();