Coverity #1247398, #1199692, #1321278, #1321279, #1321280, #1321281, #1097625 fixed... 83/17983/12
Dhruv Khattar [Fri, 25 Mar 2016 14:13:43 +0000 (19:13 +0530)]
Change-Id: I7f18dc8f899cfc25d03df41a274a64d9be3b20ea

scilab/modules/external_objects_java/sci_gateway/cpp/sci_jconvMatrixMethod.cpp
scilab/modules/gui/src/cpp/SetUicontrolIcon.cpp
scilab/modules/io/sci_gateway/cpp/sci_file.cpp
scilab/modules/linear_algebra/sci_gateway/cpp/sci_spec.cpp
scilab/modules/scinotes/src/cpp/callscinotes.cpp

index 7770071..0477d8d 100644 (file)
@@ -79,12 +79,12 @@ int sci_jconvMatrixMethod(char * fname, void* pvApiCtx)
     }
     else
     {
-        delete type;
+        FREE(type);
         Scierror(999, "%s: Invalid string: \"rc\" or \"cr\" expected.", fname);
         return 0;
     }
 
-    delete type;
+    FREE(type);
 
     LhsVar(1) = 0;
     PutLhsVar();
index 2cb4437..550db75 100644 (file)
@@ -57,7 +57,7 @@ int SetUicontrolIcon(void* _pvCtx, int iObjUID, void* _pvData, int valueType, in
         }
         else
         {
-            free(iconPath);
+            delete[] iconPath;
         }
     }
 
index 3e4f62a..0306432 100644 (file)
@@ -483,7 +483,7 @@ types::Function::ReturnValue sci_file_one_rhs(types::typed_list &in, int _iRetCo
         {
             types::String* pS = new types::String(pstType);
             out.push_back(pS);
-            delete[] pstType;
+            FREE(pstType);
         }
     }
 
@@ -494,7 +494,7 @@ types::Function::ReturnValue sci_file_one_rhs(types::typed_list &in, int _iRetCo
         {
             types::String* pS = new types::String(pstName);
             out.push_back(pS);
-            delete[] pstName;
+            FREE(pstName);
         }
     }
 
index 902b8c2..487021b 100644 (file)
@@ -329,10 +329,22 @@ types::Function::ReturnValue sci_spec(types::typed_list &in, int _iRetCount, typ
             pDataA = (double*)oGetDoubleComplexFromPointer(pDblA->getReal(), pDblA->getImg(), pDblA->getSize());
             pDataB = (double*)oGetDoubleComplexFromPointer(pDblB->getReal(), pDblB->getImg(), pDblB->getSize());
 
-            if (!pDataA || !pDataB)
+            if (!pDataA && !pDataB)
             {
-                delete pDataA;
-                delete pDataB;
+                Scierror(999, _("%s: Cannot allocate more memory.\n"), "spec");
+                return types::Function::Error;
+            }
+
+            if (!pDataA)
+            {
+                vFreeDoubleComplexFromPointer((doublecomplex*)pDataB);
+                Scierror(999, _("%s: Cannot allocate more memory.\n"), "spec");
+                return types::Function::Error;
+            }
+            
+            if (!pDataB)
+            {
+                vFreeDoubleComplexFromPointer((doublecomplex*)pDataA);
                 Scierror(999, _("%s: Cannot allocate more memory.\n"), "spec");
                 return types::Function::Error;
             }
index 163833b..8d78af9 100644 (file)
@@ -129,7 +129,11 @@ int callSciNotesWWithOption(wchar_t **_wcfilenames, wchar_t** option, int _nbopt
                 }
             }
         }
-        FREE(opt);
+        for(int i = 0; i < _nboptions; i++)
+        {
+            FREE(opt[i]);
+        }
+        delete[] opt;
     }
     else
     {