Fix memory leak in compositor code with RGB curve nodes.
[blender.git] / source / blender / compositor / operations / COM_CurveBaseOperation.cpp
index 408395bfcf0397df7779c1d16a65ad7b5ebbaab3..9bb5ac88343654a4b64a4f0e7e5cf03bbb1f6b55 100644 (file)
@@ -34,14 +34,25 @@ CurveBaseOperation::CurveBaseOperation() : NodeOperation()
 {
        this->m_curveMapping = NULL;
 }
+
+CurveBaseOperation::~CurveBaseOperation()
+{
+       if (this->m_curveMapping) {
+               curvemapping_free(this->m_curveMapping);
+               this->m_curveMapping = NULL;
+       }
+}
+
 void CurveBaseOperation::initExecution()
 {
        curvemapping_initialize(this->m_curveMapping);
 }
 void CurveBaseOperation::deinitExecution()
 {
-       curvemapping_free(this->m_curveMapping);
-       this->m_curveMapping = NULL;
+       if (this->m_curveMapping) {
+               curvemapping_free(this->m_curveMapping);
+               this->m_curveMapping = NULL;
+       }
 }
 
 void CurveBaseOperation::setCurveMapping(CurveMapping *mapping)