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_curves.cc | |
parent | 5852c66125b706a7ab9e5e179dfa51d3bf94bbd2 (diff) |
Alembic import: don't crash Blender when reading invalid samples
Diffstat (limited to 'source/blender/alembic/intern/abc_curves.cc')
-rw-r--r-- | source/blender/alembic/intern/abc_curves.cc | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/source/blender/alembic/intern/abc_curves.cc b/source/blender/alembic/intern/abc_curves.cc index 158c325e4aa..e27403305da 100644 --- a/source/blender/alembic/intern/abc_curves.cc +++ b/source/blender/alembic/intern/abc_curves.cc @@ -256,9 +256,21 @@ void AbcCurveReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSele /* ************************************************************************** */ -void read_curve_sample(Curve *cu, const ICurvesSchema &schema, const ISampleSelector &sample_sel) +void AbcCurveReader::read_curve_sample(Curve *cu, const ICurvesSchema &schema, const ISampleSelector &sample_sel) { - ICurvesSchema::Sample smp = schema.getValue(sample_sel); + ICurvesSchema::Sample smp; + try { + smp = schema.getValue(sample_sel); + } + catch(Alembic::Util::Exception &ex) { + printf("Alembic: error reading curve sample for '%s/%s' at time %f: %s\n", + m_iobject.getFullName().c_str(), + schema.getName().c_str(), + sample_sel.getRequestedTime(), + ex.what()); + return; + } + const Int32ArraySamplePtr num_vertices = smp.getCurvesNumVertices(); const P3fArraySamplePtr positions = smp.getPositions(); const FloatArraySamplePtr weights = smp.getPositionWeights(); @@ -404,12 +416,25 @@ void read_curve_sample(Curve *cu, const ICurvesSchema &schema, const ISampleSele * object directly and create a new Mesh from that. Also we might need to * create new or delete existing NURBS in the curve. */ -Mesh *AbcCurveReader::read_mesh(Mesh * /*existing_mesh*/, +Mesh *AbcCurveReader::read_mesh(Mesh *existing_mesh, const ISampleSelector &sample_sel, int /*read_flag*/, - const char ** /*err_str*/) + const char **err_str) { - const ICurvesSchema::Sample sample = m_curves_schema.getValue(sample_sel); + ICurvesSchema::Sample sample; + + try { + sample = m_curves_schema.getValue(sample_sel); + } + catch(Alembic::Util::Exception &ex) { + *err_str = "Error reading curve sample; more detail on the console"; + printf("Alembic: error reading curve sample for '%s/%s' at time %f: %s\n", + m_iobject.getFullName().c_str(), + m_curves_schema.getName().c_str(), + sample_sel.getRequestedTime(), + ex.what()); + return existing_mesh; + } const P3fArraySamplePtr &positions = sample.getPositions(); const Int32ArraySamplePtr num_vertices = sample.getCurvesNumVertices(); |