diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2018-06-07 19:34:05 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2018-06-07 20:01:45 +0300 |
commit | 9a873d0ab2448b0fd059e87f339db07dc648510f (patch) | |
tree | 1f1071160ef36a63f30852825460b2d17624fab5 /source/blender/alembic/intern/abc_mesh.cc | |
parent | 5852c66125b706a7ab9e5e179dfa51d3bf94bbd2 (diff) |
Alembic import: don't crash Blender when reading invalid samples
Diffstat (limited to 'source/blender/alembic/intern/abc_mesh.cc')
-rw-r--r-- | source/blender/alembic/intern/abc_mesh.cc | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc index a593bf21328..e09852e328e 100644 --- a/source/blender/alembic/intern/abc_mesh.cc +++ b/source/blender/alembic/intern/abc_mesh.cc @@ -1062,7 +1062,19 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh, int read_flag, const char **err_str) { - const IPolyMeshSchema::Sample sample = m_schema.getValue(sample_sel); + IPolyMeshSchema::Sample sample; + try { + sample = m_schema.getValue(sample_sel); + } + catch(Alembic::Util::Exception &ex) { + *err_str = "Error reading mesh sample; more detail on the console"; + printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n", + m_iobject.getFullName().c_str(), + m_schema.getName().c_str(), + sample_sel.getRequestedTime(), + ex.what()); + return existing_mesh; + } const P3fArraySamplePtr &positions = sample.getPositions(); const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices(); @@ -1300,7 +1312,19 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, NULL); BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, CD_MASK_MESH, true); - const ISubDSchema::Sample sample = m_schema.getValue(sample_sel); + ISubDSchema::Sample sample; + try { + sample = m_schema.getValue(sample_sel); + } + catch(Alembic::Util::Exception &ex) { + printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n", + m_iobject.getFullName().c_str(), + m_schema.getName().c_str(), + sample_sel.getRequestedTime(), + ex.what()); + return; + } + Int32ArraySamplePtr indices = sample.getCreaseIndices(); Alembic::Abc::FloatArraySamplePtr sharpnesses = sample.getCreaseSharpnesses(); @@ -1335,7 +1359,19 @@ Mesh *AbcSubDReader::read_mesh(Mesh *existing_mesh, int read_flag, const char **err_str) { - const ISubDSchema::Sample sample = m_schema.getValue(sample_sel); + ISubDSchema::Sample sample; + try { + sample = m_schema.getValue(sample_sel); + } + catch(Alembic::Util::Exception &ex) { + *err_str = "Error reading mesh sample; more detail on the console"; + printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n", + m_iobject.getFullName().c_str(), + m_schema.getName().c_str(), + sample_sel.getRequestedTime(), + ex.what()); + return existing_mesh; + } const P3fArraySamplePtr &positions = sample.getPositions(); const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices(); |