[Coverity 1350443] Scicos src: Check function return 04/17804/3
Paul Bignier [Mon, 15 Feb 2016 09:06:39 +0000 (10:06 +0100)]
 * Also unlock the model when returning early

Change-Id: I43f11a93042160622adb25ba5453e5a3c3f3eab6

scilab/modules/scicos/src/cpp/Controller.cpp

index 4eb6b52..354d7f5 100644 (file)
@@ -186,6 +186,11 @@ unsigned Controller::referenceObject(const ScicosID uid) const
 
     auto o = m_instance.model.getObject(uid);
     unlock(&m_instance.onModelStructuralModification);
+    if (o == nullptr)
+    {
+        // defensive programming
+        return 0u;
+    }
 
     lock(&m_instance.onViewsStructuralModification);
     for (view_set_t::iterator iter = m_instance.allViews.begin(); iter != m_instance.allViews.end(); ++iter)
@@ -211,6 +216,7 @@ void Controller::deleteObject(ScicosID uid)
     if (initial == nullptr)
     {
         // defensive programming
+        unlock(&m_instance.onModelStructuralModification);
         return;
     }
     const kind_t k = initial->kind();