Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaia Clary <gaia.clary@machinimatrix.org>2018-03-11 22:00:46 +0300
committerGaia Clary <gaia.clary@machinimatrix.org>2018-03-11 22:59:49 +0300
commitca11ef7fd3de97f8f56d3b1a27972fd23eb6cea8 (patch)
treee9280d64b6954ceaba5393701d32ae8c550ca790 /source/blender/collada
parent2de0daa179617c4eb759f6298485a577e7ee2dfe (diff)
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.
Diffstat (limited to 'source/blender/collada')
-rw-r--r--source/blender/collada/AnimationExporter.cpp18
1 files changed, 12 insertions, 6 deletions
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;
}