diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-03-10 19:15:29 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-03-10 19:16:12 +0300 |
commit | a6d7280b8e1c8ac7c0d6ebcf134290836413168c (patch) | |
tree | 63da1023270429ce557ad1d3499802a1fcb16972 /source/blender/io/alembic/intern/abc_reader_mesh.cc | |
parent | 7c027f9480a9dfa4e9a478a27300cff89a7f000a (diff) |
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.
Diffstat (limited to 'source/blender/io/alembic/intern/abc_reader_mesh.cc')
-rw-r--r-- | source/blender/io/alembic/intern/abc_reader_mesh.cc | 15 |
1 files changed, 15 insertions, 0 deletions
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. */ |