[Bf-blender-cvs] [ca11ef7fd3d] master: Fix Collada: Avoid unnecessary and even wrong check on unavailable data

Gaia Clary noreply at git.blender.org
Sun Mar 11 21:00:07 CET 2018


Commit: ca11ef7fd3de97f8f56d3b1a27972fd23eb6cea8
Author: Gaia Clary
Date:   Sun Mar 11 20:00:46 2018 +0100
Branches: master
https://developer.blender.org/rBca11ef7fd3de97f8f56d3b1a27972fd23eb6cea8

Fix Collada: Avoid unnecessary and even wrong check on unavailable data

The function validateConstraints() potentially causes a null pointer
exception. I changed this so that the function returns a failure as soon
as the validation fails. This avoids falling into the null pointer trap.

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

M	source/blender/collada/AnimationExporter.cpp

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

diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 97d3b6b29b8..5492fcbb625 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -1926,15 +1926,21 @@ void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, i
 
 bool AnimationExporter::validateConstraints(bConstraint *con)
 {
-	bool valid = true;
 	const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
 	/* these we can skip completely (invalid constraints...) */
-	if (cti == NULL) valid = false;
-	if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) valid = false;
+	if (cti == NULL)
+		return false;
+	if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF))
+		return false;
+
 	/* these constraints can't be evaluated anyway */
-	if (cti->evaluate_constraint == NULL) valid = false;
+	if (cti->evaluate_constraint == NULL)
+		return false;
+
 	/* influence == 0 should be ignored */
-	if (con->enforce == 0.0f) valid = false;
+	if (con->enforce == 0.0f)
+		return false;
 
-	return valid;
+	/* validation passed */
+	return true;
 }



More information about the Bf-blender-cvs mailing list