[Libreoffice-commits] core.git: starmath/source

Takeshi Abe tabe at fixedpoint.jp
Wed Nov 5 19:56:50 PST 2014


 starmath/source/node.cxx |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

New commits:
commit 8b21b5cbe78945b27525b4ce78ae3d981f90590f
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Thu Nov 6 12:54:02 2014 +0900

    Avoid possible memory leaks in case of exception
    
    Change-Id: Ie8c1a3e54bda4ec650f5d5da3928d3c44e4008a8

diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 7c93b14..bb2006a 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -36,7 +36,7 @@
 
 #include <math.h>
 #include <float.h>
-
+#include <boost/scoped_array.hpp>
 
 
 SmNode::SmNode(SmNodeType eNodeType, const SmToken &rNodeToken)
@@ -2558,7 +2558,7 @@ void SmMatrixNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
 
     // initialize array that is to hold the maximum widths of all
     // elements (subnodes) in that column.
-    long *pColWidth = new long[nNumCols];
+    boost::scoped_array<long> pColWidth(new long[nNumCols]);
     for (j = 0;  j  < nNumCols;  j++)
         pColWidth[j] = 0;
 
@@ -2584,7 +2584,7 @@ void SmMatrixNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
           nVerDist = nNormDist * rFormat.GetDistance(DIS_MATRIXROW) / 100L;
 
     // build array that holds the leftmost position for each column
-    long *pColLeft = new long[nNumCols];
+    boost::scoped_array<long> pColLeft(new long[nNumCols]);
     long  nX = 0;
     for (j = 0;  j < nNumCols;  j++)
     {   pColLeft[j] = nX;
@@ -2644,9 +2644,6 @@ void SmMatrixNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
 
         ExtendBy(aLineRect, RCP_NONE);
     }
-
-    delete [] pColLeft;
-    delete [] pColWidth;
 }
 
 


More information about the Libreoffice-commits mailing list