From 597314322ff0c92ca0a421772c6aef000da113d7 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 28 Dec 2020 01:01:30 +0100 Subject: [PATCH] sokol: fix a crash when handling a corrupt image --- thirdparty/sokol/sokol_gfx.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/thirdparty/sokol/sokol_gfx.h b/thirdparty/sokol/sokol_gfx.h index 35385dd526..3ca8eb72fa 100644 --- a/thirdparty/sokol/sokol_gfx.h +++ b/thirdparty/sokol/sokol_gfx.h @@ -9490,7 +9490,8 @@ _SOKOL_PRIVATE void _sg_mtl_copy_image_content(const _sg_image_t* img, __unsafe_ for (int slice_index = 0; slice_index < num_slices; slice_index++) { const int mtl_slice_index = (img->cmn.type == SG_IMAGETYPE_CUBE) ? face_index : slice_index; const int slice_offset = slice_index * bytes_per_slice; -/// SOKOL_ASSERT((slice_offset + bytes_per_slice) <= (int)content->subimage[face_index][mip_index].size); +// SOKOL_ASSERT((slice_offset + bytes_per_slice) <= (int)content->subimage[face_index][mip_index].size); + if (!((slice_offset + bytes_per_slice) <= (int)content->subimage[face_index][mip_index].size)) continue; [mtl_tex replaceRegion:region mipmapLevel:mip_index slice:mtl_slice_index