ast: fix Coverity #1407683 and #1407684 34/21134/2
Clément DAVID [Thu, 21 Nov 2019 08:15:18 +0000 (09:15 +0100)]
Change-Id: I2b71788ea0037b3924bb2a2b4a75ab9d8b37f9a0

scilab/modules/ast/src/cpp/types/double.cpp

index c6f31f2..aa38282 100644 (file)
@@ -402,12 +402,9 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i
         int iBlankSize = df.bPrintBlank ? BLANK_SIZE : 0;
 
         //Array with the max printed size of each col
-        int *piSize = new int[getCols()];
-        int *piRSize = new int[getCols()];
-        int *piISize = new int[getCols()];
-        memset(piSize, 0x00, getCols() * sizeof(int));
-        memset(piRSize, 0x00, getCols() * sizeof(int));
-        memset(piISize, 0x00, getCols() * sizeof(int));
+        std::vector<int> piSize(getCols());
+        std::vector<int> piRSize(getCols());
+        std::vector<int> piISize(getCols());
 
         if (isComplex() == false)
         {
@@ -446,7 +443,6 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i
                             ostr << ostemp.str();
                             m_iRows2PrintState = iRows2;
                             m_iCols1PrintState = iLastCol;
-                            delete[] piSize;
                             return false;
                         }
 
@@ -499,7 +495,6 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i
                     ostr << ostemp.str();
                     m_iRows2PrintState = iRows2;
                     m_iCols1PrintState = iLastCol;
-                    delete[] piSize;
                     return false;
                 }
 
@@ -566,9 +561,6 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i
                             ostr << ostemp.str();
                             m_iRows2PrintState = iRows2;
                             m_iCols1PrintState = iLastCol;
-                            delete[] piSize;
-                            delete[] piRSize;
-                            delete[] piISize;
                             return false;
                         }
 
@@ -623,8 +615,6 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i
                     ostr << ostemp.str();
                     m_iRows2PrintState = iRows2;
                     m_iCols1PrintState = iLastCol;
-                    delete[] piSize;
-                    delete[] piRSize;
                     return false;
                 }
 
@@ -653,10 +643,6 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i
             }
             ostr << ostemp.str();
         }
-
-        delete[] piSize;
-        delete[] piRSize;
-        delete[] piISize;
     }
 
     return true;
@@ -1097,7 +1083,7 @@ void Double::convertToZComplex()
 
     if (isComplex())
     {
-        pdblZ = oGetDoubleComplexFromPointer(getReal(), getImg() , getSize());
+        pdblZ = oGetDoubleComplexFromPointer(getReal(), getImg(), getSize());
         delete[] m_pImgData;
         m_pImgData = NULL;
     }