[Bf-blender-cvs] [e981f0e] alembic_basic_io: Fix crash accessing arrays out of bounds.

Kévin Dietrich noreply at git.blender.org
Wed Jun 22 17:21:40 CEST 2016


Commit: e981f0e4a029337a24a9b581a16ebd106c5845e4
Author: Kévin Dietrich
Date:   Wed Jun 22 17:05:00 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rBe981f0e4a029337a24a9b581a16ebd106c5845e4

Fix crash accessing arrays out of bounds.

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

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

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

diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index b6b870b..1201493 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -979,16 +979,18 @@ void AbcMeshReader::readPolyDataSample(Mesh *mesh,
 		uvs = uvsamp.getVals();
 		uvs_indices = uvsamp.getIndices();
 
-		std::string name = Alembic::Abc::GetSourceName(uv.getMetaData());
+		if (uvs_indices->size() == mesh->totloop) {
+			std::string name = Alembic::Abc::GetSourceName(uv.getMetaData());
+
+			/* According to the convention, primary UVs should have had their name
+			 * set using Alembic::Abc::SetSourceName, but you can't expect everyone
+			 * to follow it! :) */
+			if (name.empty()) {
+				name = uv.getName();
+			}
 
-		/* According to the convention, primary UVs should have had their name
-		 * set using Alembic::Abc::SetSourceName, but you can't expect everyone
-		 * to follow it! :) */
-		if (name.empty()) {
-			name = uv.getName();
+			ED_mesh_uv_texture_add(mesh, name.c_str(), true);
 		}
-
-		ED_mesh_uv_texture_add(mesh, name.c_str(), true);
 	}
 
 	read_mpolys(mesh->mpoly, mesh->mloop, mesh->mloopuv, &mesh->ldata,
@@ -1109,7 +1111,7 @@ void read_mpolys(MPoly *mpolys, MLoop *mloops, MLoopUV *mloopuvs, CustomData *ld
 	}
 
 	const bool do_normals = (normals && pnors);
-	const bool do_uvs = (mloopuvs && uvs && uvs_indices);
+	const bool do_uvs = (mloopuvs && uvs && uvs_indices) && (uvs_indices->size() == face_indices->size());
 	unsigned int loop_index = 0;
 	unsigned int rev_loop_index = 0;
 	unsigned int uv_index = 0;
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 4638309..0067216 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -776,6 +776,11 @@ static DerivedMesh *read_mesh_sample(DerivedMesh *dm, const IObject &iobject, co
 		uv.getIndexed(uvsamp, sample_sel);
 		uvs = uvsamp.getVals();
 		uvs_indices = uvsamp.getIndices();
+
+		if (uvs_indices->size() != dm->getNumLoops(dm)) {
+			uvs = Alembic::Abc::V2fArraySamplePtr();
+			uvs_indices = Alembic::Abc::UInt32ArraySamplePtr();
+		}
 	}
 
 	N3fArraySamplePtr vertex_normals, poly_normals;




More information about the Bf-blender-cvs mailing list