Commit: e95a686a08f6a64544f383083b96dd2ce94ea973
Author: Kévin Dietrich
Date:   Thu Jun 16 15:27:20 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rBe95a686a08f6a64544f383083b96dd2ce94ea973

Fix crash accessing non-existing property.

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

M       source/blender/alembic/intern/abc_points.cc
M       source/blender/alembic/intern/abc_util.cc
M       source/blender/alembic/intern/abc_util.h
M       source/blender/alembic/intern/alembic_capi.cc

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

diff --git a/source/blender/alembic/intern/abc_points.cc 
b/source/blender/alembic/intern/abc_points.cc
index db5c545..690305d 100644
--- a/source/blender/alembic/intern/abc_points.cc
+++ b/source/blender/alembic/intern/abc_points.cc
@@ -163,7 +163,7 @@ void AbcPointsReader::readObjectData(Main *bmain, Scene 
*scene, float time)
        ICompoundProperty prop = m_schema.getArbGeomParams();
        N3fArraySamplePtr vnormals;
 
-       if (prop.valid()) {
+       if (has_property(prop, "N")) {
                const IN3fArrayProperty &normals_prop = IN3fArrayProperty(prop, 
"N", time);
 
                if (normals_prop) {
diff --git a/source/blender/alembic/intern/abc_util.cc 
b/source/blender/alembic/intern/abc_util.cc
index e34330c9..a0f874a 100644
--- a/source/blender/alembic/intern/abc_util.cc
+++ b/source/blender/alembic/intern/abc_util.cc
@@ -433,3 +433,12 @@ void create_transform_matrix(Object *obj, float 
transform_mat[4][4])
        /* Add scale to transformation matrix. */
        mul_m4_m4m4(transform_mat, transform_mat, scale_mat);
 }
+
+bool has_property(const Alembic::Abc::ICompoundProperty &prop, const 
std::string &name)
+{
+       if (!prop.valid()) {
+               return false;
+       }
+
+       return prop.getPropertyHeader(name) != NULL;
+}
diff --git a/source/blender/alembic/intern/abc_util.h 
b/source/blender/alembic/intern/abc_util.h
index 345b71e..6f246cc 100644
--- a/source/blender/alembic/intern/abc_util.h
+++ b/source/blender/alembic/intern/abc_util.h
@@ -74,6 +74,8 @@ void get_min_max_time(const Schema &schema, chrono_t &min, 
chrono_t &max)
        }
 }
 
+bool has_property(const Alembic::Abc::ICompoundProperty &prop, const 
std::string &name);
+
 /* ************************** */
 
 /* TODO: this duplicates MINLINE from BLI_math, but then need to keep things
diff --git a/source/blender/alembic/intern/alembic_capi.cc 
b/source/blender/alembic/intern/alembic_capi.cc
index 1a1322c..1ed3253 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -768,7 +768,7 @@ static DerivedMesh *read_points_sample(DerivedMesh *dm, 
const IObject &iobject,
        ICompoundProperty prop = schema.getArbGeomParams();
        N3fArraySamplePtr vnormals;
 
-       if (prop.valid()) {
+       if (has_property(prop, "N")) {
                const IN3fArrayProperty &normals_prop = IN3fArrayProperty(prop, 
"N", 0);
 
                if (normals_prop) {

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to