Avoid possible memory leaks in case of exceptions
Change-Id: Id71cb49d8aa241a17efd4cbe217a48f2d7c34e84
This commit is contained in:
@@ -47,6 +47,7 @@
|
|||||||
|
|
||||||
#include <LibXSLTTransformer.hxx>
|
#include <LibXSLTTransformer.hxx>
|
||||||
#include <OleHandler.hxx>
|
#include <OleHandler.hxx>
|
||||||
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
using namespace ::rtl;
|
using namespace ::rtl;
|
||||||
using namespace ::cppu;
|
using namespace ::cppu;
|
||||||
@@ -307,11 +308,11 @@ namespace XSLT
|
|||||||
xsltSetGenericDebugFunc(stderr, NULL);
|
xsltSetGenericDebugFunc(stderr, NULL);
|
||||||
xsltDebugDumpExtensions(NULL);
|
xsltDebugDumpExtensions(NULL);
|
||||||
#endif
|
#endif
|
||||||
OleHandler* oh = new OleHandler(m_transformer->getComponentContext());
|
boost::scoped_ptr<OleHandler> oh(new OleHandler(m_transformer->getComponentContext()));
|
||||||
if (styleSheet)
|
if (styleSheet)
|
||||||
{
|
{
|
||||||
tcontext = xsltNewTransformContext(styleSheet, doc);
|
tcontext = xsltNewTransformContext(styleSheet, doc);
|
||||||
tcontext->_private = static_cast<void *> (oh);
|
tcontext->_private = static_cast<void *> (oh.get());
|
||||||
xsltQuoteUserParams(tcontext, ¶ms[0]);
|
xsltQuoteUserParams(tcontext, ¶ms[0]);
|
||||||
result = xsltApplyStylesheetUser(styleSheet, doc, 0, 0, 0,
|
result = xsltApplyStylesheetUser(styleSheet, doc, 0, 0, 0,
|
||||||
tcontext);
|
tcontext);
|
||||||
@@ -340,7 +341,7 @@ namespace XSLT
|
|||||||
m_transformer->error(msg);
|
m_transformer->error(msg);
|
||||||
}
|
}
|
||||||
closeOutput();
|
closeOutput();
|
||||||
delete(oh);
|
oh.reset();
|
||||||
xsltFreeStylesheet(styleSheet);
|
xsltFreeStylesheet(styleSheet);
|
||||||
xsltFreeTransformContext(tcontext);
|
xsltFreeTransformContext(tcontext);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
#include <com/sun/star/embed/XTransactedObject.hpp>
|
#include <com/sun/star/embed/XTransactedObject.hpp>
|
||||||
|
|
||||||
#include <OleHandler.hxx>
|
#include <OleHandler.hxx>
|
||||||
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
using namespace ::com::sun::star::uno;
|
using namespace ::com::sun::star::uno;
|
||||||
using namespace ::com::sun::star::lang;
|
using namespace ::com::sun::star::lang;
|
||||||
@@ -128,12 +129,12 @@ namespace XSLT
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Decompress the bytes
|
// Decompress the bytes
|
||||||
::ZipUtils::Inflater* decompresser = new ::ZipUtils::Inflater(false);
|
boost::scoped_ptr< ::ZipUtils::Inflater> decompresser(new ::ZipUtils::Inflater(false));
|
||||||
decompresser->setInput(content);
|
decompresser->setInput(content);
|
||||||
Sequence<sal_Int8> result(oleLength);
|
Sequence<sal_Int8> result(oleLength);
|
||||||
decompresser->doInflateSegment(result, 0, oleLength);
|
decompresser->doInflateSegment(result, 0, oleLength);
|
||||||
decompresser->end();
|
decompresser->end();
|
||||||
delete decompresser;
|
decompresser.reset();
|
||||||
//return the base64 string of the uncompressed data
|
//return the base64 string of the uncompressed data
|
||||||
OUStringBuffer buf(oleLength);
|
OUStringBuffer buf(oleLength);
|
||||||
::sax::Converter::encodeBase64(buf, result);
|
::sax::Converter::encodeBase64(buf, result);
|
||||||
@@ -196,11 +197,11 @@ namespace XSLT
|
|||||||
|
|
||||||
// Compress the bytes
|
// Compress the bytes
|
||||||
Sequence<sal_Int8> output(oledata.getLength());
|
Sequence<sal_Int8> output(oledata.getLength());
|
||||||
::ZipUtils::Deflater* compresser = new ::ZipUtils::Deflater((sal_Int32) 3, false);
|
boost::scoped_ptr< ::ZipUtils::Deflater> compresser(new ::ZipUtils::Deflater((sal_Int32) 3, false));
|
||||||
compresser->setInputSegment(oledata, 0, oledata.getLength());
|
compresser->setInputSegment(oledata, 0, oledata.getLength());
|
||||||
compresser->finish();
|
compresser->finish();
|
||||||
int compressedDataLength = compresser->doDeflateSegment(output, 0, oledata.getLength());
|
int compressedDataLength = compresser->doDeflateSegment(output, 0, oledata.getLength());
|
||||||
delete(compresser);
|
compresser.reset();
|
||||||
//realloc the data length
|
//realloc the data length
|
||||||
Sequence<sal_Int8> compressed(compressedDataLength);
|
Sequence<sal_Int8> compressed(compressedDataLength);
|
||||||
for (int i = 0; i < compressedDataLength; i++) {
|
for (int i = 0; i < compressedDataLength; i++) {
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
#include "EventThread.hxx"
|
#include "EventThread.hxx"
|
||||||
#include <comphelper/guarding.hxx>
|
#include <comphelper/guarding.hxx>
|
||||||
#include <tools/debug.hxx>
|
#include <tools/debug.hxx>
|
||||||
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
namespace frm
|
namespace frm
|
||||||
{
|
{
|
||||||
@@ -176,7 +176,7 @@ void OComponentEventThread::run()
|
|||||||
::cppu::OComponentHelper *pCompImpl = m_pCompImpl;
|
::cppu::OComponentHelper *pCompImpl = m_pCompImpl;
|
||||||
|
|
||||||
ThreadEvents::iterator firstEvent( m_aEvents.begin() );
|
ThreadEvents::iterator firstEvent( m_aEvents.begin() );
|
||||||
EventObject* pEvt = *firstEvent;
|
boost::scoped_ptr<EventObject> pEvt(*firstEvent);
|
||||||
m_aEvents.erase( firstEvent );
|
m_aEvents.erase( firstEvent );
|
||||||
|
|
||||||
ThreadObjects::iterator firstControl( m_aControls.begin() );
|
ThreadObjects::iterator firstControl( m_aControls.begin() );
|
||||||
@@ -196,10 +196,8 @@ void OComponentEventThread::run()
|
|||||||
query_interface(xControlAdapter->queryAdapted(), xControl);
|
query_interface(xControlAdapter->queryAdapted(), xControl);
|
||||||
|
|
||||||
if( xComp.is() )
|
if( xComp.is() )
|
||||||
processEvent( pCompImpl, pEvt, xControl, bFlag );
|
processEvent( pCompImpl, pEvt.get(), xControl, bFlag );
|
||||||
}
|
}
|
||||||
|
|
||||||
delete pEvt;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// After a Dispose, we do not know the Control anymore.
|
// After a Dispose, we do not know the Control anymore.
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
namespace frm
|
namespace frm
|
||||||
{
|
{
|
||||||
@@ -85,14 +85,13 @@ namespace frm
|
|||||||
RichTextEngine* pClone( NULL );
|
RichTextEngine* pClone( NULL );
|
||||||
{
|
{
|
||||||
SolarMutexGuard aGuard;
|
SolarMutexGuard aGuard;
|
||||||
EditTextObject* pMyText = CreateTextObject();
|
boost::scoped_ptr<EditTextObject> pMyText(CreateTextObject());
|
||||||
OSL_ENSURE( pMyText, "RichTextEngine::Clone: CreateTextObject returned nonsense!" );
|
OSL_ENSURE( pMyText, "RichTextEngine::Clone: CreateTextObject returned nonsense!" );
|
||||||
|
|
||||||
pClone = Create();
|
pClone = Create();
|
||||||
|
|
||||||
if ( pMyText )
|
if ( pMyText )
|
||||||
pClone->SetText( *pMyText );
|
pClone->SetText( *pMyText );
|
||||||
delete pMyText;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pClone;
|
return pClone;
|
||||||
|
Reference in New Issue
Block a user