[Bf-blender-cvs] [a6d7280b8e1] master: Fix T74200: Alembic import crashes Blender
Sybren A. Stüvel
noreply at git.blender.org
Tue Mar 10 17:23:20 CET 2020
Commit: a6d7280b8e1c8ac7c0d6ebcf134290836413168c
Author: Sybren A. Stüvel
Date: Tue Mar 10 17:15:29 2020 +0100
Branches: master
https://developer.blender.org/rBa6d7280b8e1c8ac7c0d6ebcf134290836413168c
Fix T74200: Alembic import crashes Blender
I've added a very minimal mesh validation before the Alembic mesh is actually
converted to a Blender mesh. This prevents a specific crash with an example
file attached to T74200.
===================================================================
M source/blender/io/alembic/intern/abc_reader_mesh.cc
===================================================================
diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc
index a4e412695c3..ec74fb2137e 100644
--- a/source/blender/io/alembic/intern/abc_reader_mesh.cc
+++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc
@@ -564,6 +564,21 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices();
const Alembic::Abc::Int32ArraySamplePtr &face_counts = sample.getFaceCounts();
+ /* Do some very minimal mesh validation. */
+ const int poly_count = face_counts->size();
+ const int loop_count = face_indices->size();
+ /* This is the same test as in poly_to_tri_count(). */
+ if (poly_count > 0 && loop_count < poly_count * 2) {
+ if (err_str != nullptr) {
+ *err_str = "Invalid mesh; more detail on the console";
+ }
+ printf("Alembic: invalid mesh sample for '%s/%s' at time %f, less than 2 loops per face\n",
+ m_iobject.getFullName().c_str(),
+ m_schema.getName().c_str(),
+ sample_sel.getRequestedTime());
+ return existing_mesh;
+ }
+
Mesh *new_mesh = NULL;
/* Only read point data when streaming meshes, unless we need to create new ones. */
More information about the Bf-blender-cvs
mailing list