Coverity #1321207, #1321204, #1350390 fixed 52/18352/3
Dhruv Khattar [Mon, 4 Jul 2016 11:39:15 +0000 (16:39 +0530)]
Change-Id: Ieb735353faefd47144657d202cf8c4f88dcef471

scilab/modules/ast/src/cpp/symbol/variables.cpp
scilab/modules/ast/src/cpp/types/sparse.cpp

index 3578427..99445cf 100644 (file)
@@ -141,9 +141,12 @@ bool Variable::put(types::InternalType* _pIT, int _iLevel)
             // _pIT may contained in pIT
             // so increases ref of _pIT before kill pIT
             top()->m_pIT = _pIT;
-            _pIT->IncreaseRef();
-            pIT->DecreaseRef();
-            pIT->killMe();
+            if (pIT)
+            {
+                _pIT->IncreaseRef();
+                pIT->DecreaseRef();
+                pIT->killMe();
+            }
         }
     }
 
index 30a9f1b..c891f90 100644 (file)
@@ -1757,7 +1757,11 @@ GenericType* Sparse::extract(typed_list* _pArgs)
                     {
                         delete pOut;
                         pOut = NULL;
-                        break;
+                        delete[] piMaxDim;
+                        delete[] piCountDim;
+                        //free pArg content
+                        cleanIndexesArguments(_pArgs, &pArg);
+                        return NULL;
                     }
                     if (isComplex())
                     {
@@ -3754,7 +3758,11 @@ GenericType* SparseBool::extract(typed_list* _pArgs)
                     {
                         delete pOut;
                         pOut = NULL;
-                        break;
+                        delete[] piMaxDim;
+                        delete[] piCountDim;
+                        //free pArg content
+                        cleanIndexesArguments(_pArgs, &pArg);
+                        return NULL;
                     }
                     bool bValue = get((int)pIdxRow[iRow] - 1, (int)pIdxCol[iCol] - 1);
                     if (bValue)