Coverity #1321214, #1321215, #1321217, #1321220, #1321223, #1321224, #1321221, #13212... 87/17987/2
Dhruv Khattar [Sun, 27 Mar 2016 06:15:30 +0000 (11:15 +0530)]
Change-Id: I2e82c8c01cc20c66650db36090031ecabbdefeb7

scilab/modules/optimization/sci_gateway/cpp/sci_fsolve.cpp
scilab/modules/optimization/sci_gateway/cpp/sci_lsqrsolve.cpp
scilab/modules/optimization/sci_gateway/cpp/sci_readmps.cpp
scilab/modules/optimization/sci_gateway/cpp/sci_semidef.cpp
scilab/modules/polynomials/sci_gateway/cpp/sci_roots.cpp
scilab/modules/polynomials/sci_gateway/cpp/sci_sfact.cpp
scilab/modules/sparse/sci_gateway/cpp/sci_lusolve.cpp
scilab/modules/ui_data/sci_gateway/cpp/sci_editvar.cpp

index 133baa0..9f244d5 100644 (file)
@@ -290,20 +290,20 @@ types::Function::ReturnValue sci_fsolve(types::typed_list &in, int _iRetCount, t
         sciprint(_("%s: exception caught in '%s' subroutine.\n"), "fsolve", pstrFunc);
         Scierror(999, pstrMsg);
         FREE(pstrMsg);
-        delete pdblWork;
+        delete[] pdblWork;
         delete pDblX;
         if (pdblJac)
         {
-            delete pdblJac;
+            delete[] pdblJac;
         }
 
         return types::Function::Error;
     }
 
-    delete pdblWork;
+    delete[] pdblWork;
     if (pdblJac)
     {
-        delete pdblJac;
+        delete[] pdblJac;
     }
 
     /*** return output arguments ***/
index 3cbf0b6..fa63b39 100644 (file)
@@ -373,31 +373,31 @@ types::Function::ReturnValue sci_lsqrsolve(types::typed_list &in, int _iRetCount
         Scierror(999, pstrMsg);
         FREE(pstrMsg);
         delete pDblX;
-        delete piPvt;
-        delete pDblQtf;
-        delete pdblWork1;
-        delete pdblWork2;
-        delete pdblWork3;
-        delete pdblWork4;
-        delete pdblJac;
+        delete[] piPvt;
+        delete[] pDblQtf;
+        delete[] pdblWork1;
+        delete[] pdblWork2;
+        delete[] pdblWork3;
+        delete[] pdblWork4;
+        delete[] pdblJac;
         if (iMode != 2)
         {
-            delete pdblDiag;
+            delete[] pdblDiag;
         }
 
         return types::Function::Error;
     }
 
-    delete piPvt;
-    delete pDblQtf;
-    delete pdblWork1;
-    delete pdblWork2;
-    delete pdblWork3;
-    delete pdblWork4;
-    delete pdblJac;
+    delete[] piPvt;
+    delete[] pDblQtf;
+    delete[] pdblWork1;
+    delete[] pdblWork2;
+    delete[] pdblWork3;
+    delete[] pdblWork4;
+    delete[] pdblJac;
     if (iMode != 2)
     {
-        delete pdblDiag;
+        delete[] pdblDiag;
     }
 
     /*** return output arguments ***/
index 2d1b2f4..3235c49 100644 (file)
@@ -215,8 +215,8 @@ types::Function::ReturnValue sci_readmps(types::typed_list &in, int _iRetCount,
                 pDblBnds->get() + iN, pDblBnds->get(), pdblRelt,
                 bsiz, 8L, 8L, 8L, 8L, 8L);
 
-    delete piRow;
-    delete pdblRelt;
+    delete[] piRow;
+    delete[] pdblRelt;
 
     mlunit = -lunit;
     C2F(clunit)(&mlunit, NULL, piMode, 0);
@@ -282,7 +282,7 @@ types::Function::ReturnValue sci_readmps(types::typed_list &in, int _iRetCount,
         pStr->set(i, pstrTemp);
     }
     pTL->append(pStr);
-    delete pstrRwName;
+    delete[] pstrRwName;
 
     pStr = new types::String(1, iN);
     for (int i = 0; i < iN; i++)
@@ -293,7 +293,7 @@ types::Function::ReturnValue sci_readmps(types::typed_list &in, int _iRetCount,
         pStr->set(i, pstrTemp);
     }
     pTL->append(pStr);
-    delete pstrClName;
+    delete[] pstrClName;
 
     pDbl = new types::Double(iM, 1);
     pdbl = pDbl->get();
@@ -302,7 +302,7 @@ types::Function::ReturnValue sci_readmps(types::typed_list &in, int _iRetCount,
         pdbl[i] = (double)piRwstat[i];
     }
     pTL->append(pDbl);
-    delete piRwstat;
+    delete[] piRwstat;
 
     pDbl = new types::Double(iM, 2);
     pdbl = pDbl->get();
@@ -311,7 +311,7 @@ types::Function::ReturnValue sci_readmps(types::typed_list &in, int _iRetCount,
         pdbl[i] = (double)piRowcod[i];
     }
     pTL->append(pDbl);
-    delete piRowcod;
+    delete[] piRowcod;
 
     pDbl = new types::Double(iN, 2);
     pdbl = pDbl->get();
@@ -320,7 +320,7 @@ types::Function::ReturnValue sci_readmps(types::typed_list &in, int _iRetCount,
         pdbl[i] = (double)piColcod[i];
     }
     pTL->append(pDbl);
-    delete piColcod;
+    delete[] piColcod;
 
     pDbl = new types::Double(iNza, 1);
     pdbl = pDbl->get();
@@ -329,7 +329,7 @@ types::Function::ReturnValue sci_readmps(types::typed_list &in, int _iRetCount,
         pdbl[i] = (double)piRwnmbs[i];
     }
     pTL->append(pDbl);
-    delete piRwnmbs;
+    delete[] piRwnmbs;
 
     pDbl = new types::Double(1, iN + 1);
     pdbl = pDbl->get();
@@ -338,7 +338,7 @@ types::Function::ReturnValue sci_readmps(types::typed_list &in, int _iRetCount,
         pdbl[i] = (double)piClpnts[i];
     }
     pTL->append(pDbl);
-    delete piClpnts;
+    delete[] piClpnts;
 
     pTL->append(pDblCoef);
     pTL->append(pDblRhsb);
@@ -352,7 +352,7 @@ types::Function::ReturnValue sci_readmps(types::typed_list &in, int _iRetCount,
         pdbl[i] = (double)piStavar[i];
     }
     pTL->append(pDbl);
-    delete piStavar;
+    delete[] piStavar;
 
     out.push_back(pTL);
     return types::Function::OK;
index 7e31a43..24284f8 100644 (file)
@@ -209,8 +209,8 @@ types::Function::ReturnValue sci_semidef(types::typed_list &in, int _iRetCount,
     C2F(spf)(&iSizeX, &iSizeB, pDblF->get(), piB, pDblC->get(), pDblX->get(), pDblZ->get(),
              pDblUl->get(), &dNu, &dAbstol, &dReltol, &dTv, &iIter, pdblWork, &iSizeWork, piWork, &iInfo);
 
-    delete pdblWork;
-    delete piWork;
+    delete[] pdblWork;
+    delete[] piWork;
 
     if (iInfo < 0)
     {
index a3181f6..94b512b 100644 (file)
@@ -185,7 +185,7 @@ types::Function::ReturnValue sci_roots(types::typed_list &in, int _iRetCount, ty
         double* pdblTempReal = new double[iSize + 1];
         C2F(dcopy)(&iSizeP1, pdblInReal, &iOne, pdblTempReal, &imOne);
         C2F(rpoly)(pdblTempReal, &iSize, pDblOut->get(), pDblOut->getImg(), &iFail);
-        delete pdblTempReal;
+        delete[] pdblTempReal;
 
         if (iFail)
         {
@@ -275,10 +275,10 @@ types::Function::ReturnValue sci_roots(types::typed_list &in, int _iRetCount, ty
 
     if (pDblIn)
     {
-        delete pdblInReal;
+        delete[] pdblInReal;
         if (bComplex)
         {
-            delete pdblInImg;
+            delete[] pdblInImg;
         }
     }
 
index 4056d72..11bb2e1 100644 (file)
@@ -97,7 +97,7 @@ types::Function::ReturnValue sci_sfact(types::typed_list &in, int _iRetCount, ty
         // perform operation
         double* pdblWork = new double[7 * n];
         C2F(sfact1)(pdblCoefOut, &iDegD2, pdblWork, &iMaxIt, &iErr);
-        delete pdblWork;
+        delete[] pdblWork;
         if (iErr == 2)
         {
             delete pSP;
@@ -153,7 +153,7 @@ types::Function::ReturnValue sci_sfact(types::typed_list &in, int _iRetCount, ty
         int nm1 = n - 1;
         iMaxIt += n;
         C2F(sfact2)(pdblOut, &iRows, &nm1, pdblWork, &iMaxIt, &iErr);
-        delete pdblWork;
+        delete[] pdblWork;
 
         if (iErr < 0)
         {
index 1c87e19..24e50e0 100644 (file)
@@ -100,9 +100,9 @@ types::Function::ReturnValue sci_lusolve(types::typed_list &in, int _iRetCount,
         C2F(lufact1)(dbl, itemsRow, colPos, &m1, &nonZeros, fmatindex, &abstol, &reltol, &nrank, &ierr);
         fact = true;
 
-        delete dbl;
-        delete colPos;
-        delete itemsRow;
+        delete[] dbl;
+        delete[] colPos;
+        delete[] itemsRow;
     }
     else
     {
index a4b2c4c..2e4c8f3 100644 (file)
@@ -99,7 +99,7 @@ void clearWrap(T ** x, int r)
         delete [] x[i];
     }
 
-    delete x;
+    delete[] x;
 }
 /*--------------------------------------------------------------------------*/
 int sci_editvar(char * fname, void* pvApiCtx)