1
0
mirror of https://github.com/godotengine/godot synced 2024-07-01 08:39:18 +00:00

Fix memory leak when ASTC compression fails

This commit is contained in:
Haoyu Qiu 2024-05-09 14:39:41 +08:00
parent c4279fe3e0
commit a35ff3c737

View File

@ -132,7 +132,10 @@ void _compress_astc(Image *r_img, Image::ASTCFormat p_format) {
int dst_mip_w, dst_mip_h;
int dst_ofs = Image::get_image_mipmap_offset_and_dimensions(width, height, target_format, i, dst_mip_w, dst_mip_h);
// Ensure that mip offset is a multiple of 8 (etcpak expects uint64_t pointer).
ERR_FAIL_COND(dst_ofs % 8 != 0);
if (unlikely(dst_ofs % 8 != 0)) {
astcenc_context_free(context);
ERR_FAIL_MSG("astcenc: Mip offset is not a multiple of 8.");
}
uint8_t *dest_mip_write = (uint8_t *)&dest_write[dst_ofs];
// Compress image.