Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2019-06-18 16:08:41 +0300
committerSybren A. Stüvel <sybren@blender.org>2019-06-18 16:08:41 +0300
commit4337bc2e6303dbd5f295878f3e7490995a62713a (patch)
tree8636a24efb6b129b352a0a018769feb1e0633e0a
parent0b73817c8cf413f2ef3222221ca1d5a279e58515 (diff)
Fix T65901: Alembic crash on out-of-bounds UV indices
An Alembic file saved by 3DS Max caused Blender to crash when importing. Either the UV indices in the file are out of bounds or they are written in a way we don't expect. In either case, this now no longer causes Blender to crash.
-rw-r--r--source/blender/alembic/intern/abc_mesh.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index 34d7e8847b1..9a00140b0fc 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -830,6 +830,8 @@ static void read_mpolys(CDStreamConfig &config, const AbcMeshData &mesh_data)
const Int32ArraySamplePtr &face_indices = mesh_data.face_indices;
const Int32ArraySamplePtr &face_counts = mesh_data.face_counts;
const V2fArraySamplePtr &uvs = mesh_data.uvs;
+ const size_t uvs_size = uvs->size();
+
const UInt32ArraySamplePtr &uvs_indices = mesh_data.uvs_indices;
const N3fArraySamplePtr &normals = mesh_data.face_normals;
@@ -861,6 +863,12 @@ static void read_mpolys(CDStreamConfig &config, const AbcMeshData &mesh_data)
MLoopUV &loopuv = mloopuvs[rev_loop_index];
uv_index = (*uvs_indices)[loop_index];
+
+ /* Some Alembic files are broken (or at least export UVs in a way we don't expect). */
+ if (uv_index >= uvs_size) {
+ continue;
+ }
+
loopuv.uv[0] = (*uvs)[uv_index][0];
loopuv.uv[1] = (*uvs)[uv_index][1];
}