summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClément DAVID <clement.david@esi-group.com>2019-11-21 09:15:18 +0100
committerAntoine ELIAS <antoine.elias@esi-group.com>2019-12-03 17:51:35 +0100
commit20485194c16bb9829d6c4fde92561b9685d3777f (patch)
tree4b8aa3737986cb914b84ba6e81cf60516fc58b77
parentd9e09370807096d7a74057abc9d99f34d704278b (diff)
downloadscilab-20485194c16bb9829d6c4fde92561b9685d3777f.zip
scilab-20485194c16bb9829d6c4fde92561b9685d3777f.tar.gz
ast: fix Coverity #1407683 and #1407684
Change-Id: I2b71788ea0037b3924bb2a2b4a75ab9d8b37f9a0
-rw-r--r--scilab/modules/ast/src/cpp/types/double.cpp22
1 files changed, 4 insertions, 18 deletions
diff --git a/scilab/modules/ast/src/cpp/types/double.cpp b/scilab/modules/ast/src/cpp/types/double.cpp
index c6f31f2..aa38282 100644
--- a/scilab/modules/ast/src/cpp/types/double.cpp
+++ b/scilab/modules/ast/src/cpp/types/double.cpp
@@ -402,12 +402,9 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i
402 int iBlankSize = df.bPrintBlank ? BLANK_SIZE : 0; 402 int iBlankSize = df.bPrintBlank ? BLANK_SIZE : 0;
403 403
404 //Array with the max printed size of each col 404 //Array with the max printed size of each col
405 int *piSize = new int[getCols()]; 405 std::vector<int> piSize(getCols());
406 int *piRSize = new int[getCols()]; 406 std::vector<int> piRSize(getCols());
407 int *piISize = new int[getCols()]; 407 std::vector<int> piISize(getCols());
408 memset(piSize, 0x00, getCols() * sizeof(int));
409 memset(piRSize, 0x00, getCols() * sizeof(int));
410 memset(piISize, 0x00, getCols() * sizeof(int));
411 408
412 if (isComplex() == false) 409 if (isComplex() == false)
413 { 410 {
@@ -446,7 +443,6 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i
446 ostr << ostemp.str(); 443 ostr << ostemp.str();
447 m_iRows2PrintState = iRows2; 444 m_iRows2PrintState = iRows2;
448 m_iCols1PrintState = iLastCol; 445 m_iCols1PrintState = iLastCol;
449 delete[] piSize;
450 return false; 446 return false;
451 } 447 }
452 448
@@ -499,7 +495,6 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i
499 ostr << ostemp.str(); 495 ostr << ostemp.str();
500 m_iRows2PrintState = iRows2; 496 m_iRows2PrintState = iRows2;
501 m_iCols1PrintState = iLastCol; 497 m_iCols1PrintState = iLastCol;
502 delete[] piSize;
503 return false; 498 return false;
504 } 499 }
505 500
@@ -566,9 +561,6 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i
566 ostr << ostemp.str(); 561 ostr << ostemp.str();
567 m_iRows2PrintState = iRows2; 562 m_iRows2PrintState = iRows2;
568 m_iCols1PrintState = iLastCol; 563 m_iCols1PrintState = iLastCol;
569 delete[] piSize;
570 delete[] piRSize;
571 delete[] piISize;
572 return false; 564 return false;
573 } 565 }
574 566
@@ -623,8 +615,6 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i
623 ostr << ostemp.str(); 615 ostr << ostemp.str();
624 m_iRows2PrintState = iRows2; 616 m_iRows2PrintState = iRows2;
625 m_iCols1PrintState = iLastCol; 617 m_iCols1PrintState = iLastCol;
626 delete[] piSize;
627 delete[] piRSize;
628 return false; 618 return false;
629 } 619 }
630 620
@@ -653,10 +643,6 @@ bool Double::subMatrixToString(std::wostringstream& ostr, int* _piDims, int /*_i
653 } 643 }
654 ostr << ostemp.str(); 644 ostr << ostemp.str();
655 } 645 }
656
657 delete[] piSize;
658 delete[] piRSize;
659 delete[] piISize;
660 } 646 }
661 647
662 return true; 648 return true;
@@ -1097,7 +1083,7 @@ void Double::convertToZComplex()
1097 1083
1098 if (isComplex()) 1084 if (isComplex())
1099 { 1085 {
1100 pdblZ = oGetDoubleComplexFromPointer(getReal(), getImg() , getSize()); 1086 pdblZ = oGetDoubleComplexFromPointer(getReal(), getImg(), getSize());
1101 delete[] m_pImgData; 1087 delete[] m_pImgData;
1102 m_pImgData = NULL; 1088 m_pImgData = NULL;
1103 } 1089 }