Fix CID 1366839 : Null pointer dereference 86/18986/2
Clément DAVID [Fri, 27 Jan 2017 09:56:22 +0000 (10:56 +0100)]
Change-Id: Id1d618b02b78e4b4e7ff1f1fdf9c731b4d2a54a0

scilab/modules/scicos/src/cpp/view_scilab/GraphicsAdapter.cpp
scilab/modules/scicos/src/cpp/view_scilab/LinkAdapter.cpp

index 293acb1..28c70e0 100644 (file)
@@ -758,6 +758,12 @@ void copyOnClone(model::BaseObject* original, model::BaseObject* cloned, std::ma
 
 void GraphicsAdapter::add_partial_links_information(Controller& controller, model::BaseObject* original, model::BaseObject* cloned)
 {
+    // precondition
+    if (cloned == nullptr)
+    {
+        return;
+    }
+
     if (original->kind() == BLOCK)
     {
         // add the from / to information if applicable
@@ -769,7 +775,7 @@ void GraphicsAdapter::add_partial_links_information(Controller& controller, mode
 
     switch (original->kind())
     {
-        // handle recursion
+            // handle recursion
         case DIAGRAM:
         case BLOCK:
         {
index 07313c5..252e2c2 100644 (file)
@@ -940,9 +940,15 @@ void LinkAdapter::relink(Controller& controller, model::BaseObject* adaptee, con
 
 void LinkAdapter::add_partial_links_information(Controller& controller, model::BaseObject* original, model::BaseObject* cloned)
 {
+    // precondition
+    if (cloned == nullptr)
+    {
+        return;
+    }
+
     switch (original->kind())
     {
-        // add the from / to information if applicable
+            // add the from / to information if applicable
         case LINK:
         {
             auto it = partial_links.find(original->id());