[Bf-blender-cvs] [4337bc2e630] master: Fix T65901: Alembic crash on out-of-bounds UV indices

Sybren A. Stüvel noreply at git.blender.org
Tue Jun 18 15:09:11 CEST 2019


Commit: 4337bc2e6303dbd5f295878f3e7490995a62713a
Author: Sybren A. Stüvel
Date:   Tue Jun 18 15:08:41 2019 +0200
Branches: master
https://developer.blender.org/rB4337bc2e6303dbd5f295878f3e7490995a62713a

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.

===================================================================

M	source/blender/alembic/intern/abc_mesh.cc

===================================================================

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];
       }



More information about the Bf-blender-cvs mailing list