[Libreoffice-commits] .: 2 commits - hwpfilter/source
David Tardon
dtardon at kemper.freedesktop.org
Mon May 16 06:44:13 PDT 2011
hwpfilter/source/hwpreader.cxx | 27 ++++++++++++++++++++++++---
hwpfilter/source/solver.cpp | 1 +
2 files changed, 25 insertions(+), 3 deletions(-)
New commits:
commit 3279728a83c1a452cea471fc903dcbfab54ee595
Author: David Tardon <dtardon at redhat.com>
Date: Mon May 16 15:28:20 2011 +0200
do not leak memory
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 648737a..8efdef7 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -29,6 +29,8 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_hwpfilter.hxx"
+#include <boost/shared_ptr.hpp>
+
#include "hwpreader.hxx"
#include <math.h>
//#ifndef UDK100
@@ -84,6 +86,20 @@ static hchar sbuf[256];
static hchar *field = 0L;
static char buf[1024];
+namespace
+{
+
+template<typename T>
+struct Free
+{
+ void operator()(T* const ptr)
+ {
+ free(ptr);
+ }
+};
+
+}
+
struct HwpReaderPrivate
{
HwpReaderPrivate()
@@ -1781,7 +1797,8 @@ void HwpReader::makePageStyle()
if( hwpinfo->back_info.type == 2 ){
rstartEl(ascii("office:binary-data"), rList);
pList->clear();
- rchars(ascii(base64_encode_string((unsigned char *) hwpinfo->back_info.data, hwpinfo->back_info.size )));
+ boost::shared_ptr<char> pStr(base64_encode_string((unsigned char *) hwpinfo->back_info.data, hwpinfo->back_info.size ), Free<char>());
+ rchars(ascii(pStr.get()));
rendEl(ascii("office:binary-data"));
}
rendEl(ascii("style:background-image"));
@@ -3993,7 +4010,10 @@ void HwpReader::makePicture(Picture * hbox)
if( hbox->pictype == PICTYPE_EMBED ){
EmPicture *emp = hwpfile.GetEmPicture(hbox);
if( emp )
- rchars(ascii(base64_encode_string( emp->data, emp->size )));
+ {
+ boost::shared_ptr<char> pStr(base64_encode_string( emp->data, emp->size ), Free<char>());
+ rchars(ascii(pStr.get()));
+ }
}
else{
if( hwpfile.oledata ){
@@ -4015,7 +4035,8 @@ void HwpReader::makePicture(Picture * hbox)
rchars(ascii(""));
}
else{
- rchars(ascii(base64_encode_string( (uchar *)pObj, strlen((char *)pObj) )));
+ boost::shared_ptr<char> pStr(base64_encode_string( (uchar *)pObj, strlen((char *)pObj)), Free<char>());
+ rchars(ascii(pStr.get()));
pObj->Release();
srcsto->Release();
}
commit fc7375675283b606a73a3449ffaa9f9471bd3868
Author: David Tardon <dtardon at redhat.com>
Date: Mon May 16 15:10:28 2011 +0200
do not leak memory
diff --git a/hwpfilter/source/solver.cpp b/hwpfilter/source/solver.cpp
index eec1345..2fa1336 100644
--- a/hwpfilter/source/solver.cpp
+++ b/hwpfilter/source/solver.cpp
@@ -43,6 +43,7 @@ double** mgcLinearSystemD::NewMatrix (int N)
{
for (int i = 0; i < row; i++)
delete[] A[i];
+ delete[] A;
return 0;
}
for (int col = 0; col < N; col++)
More information about the Libreoffice-commits
mailing list