diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-04-24 00:09:19 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2014-04-24 00:13:28 +0900 |
commit | 1ec836760853e9e220d471cf39f2533f0828f00e (patch) | |
tree | aa481fb529d129a16af492818f63858a1af757d8 /sax/source/expatwrap/saxwriter.cxx | |
parent | 2ea006fb605b886f9c9426783e4edf0de46c9af8 (diff) |
Avoid possible memory leaks in case of exceptions
Change-Id: I047fd88a89900153089a55b6af123f11fb8bde55
Diffstat (limited to 'sax/source/expatwrap/saxwriter.cxx')
-rw-r--r-- | sax/source/expatwrap/saxwriter.cxx | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sax/source/expatwrap/saxwriter.cxx b/sax/source/expatwrap/saxwriter.cxx index 140bcfbca9f2..4dee83d543aa 100644 --- a/sax/source/expatwrap/saxwriter.cxx +++ b/sax/source/expatwrap/saxwriter.cxx @@ -49,6 +49,7 @@ using namespace ::com::sun::star::util; using namespace ::com::sun::star::io; #include "xml2utf.hxx" +#include <boost/scoped_array.hpp> namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; @@ -493,11 +494,11 @@ inline void SaxWriterHelper::insertIndentation(sal_uInt32 m_nLevel) throw( SAXEx else { sal_uInt32 nCount(m_nLevel + 1); - sal_Int8* pBytes = new sal_Int8[nCount]; + boost::scoped_array<sal_Int8> pBytes(new sal_Int8[nCount]); pBytes[0] = LINEFEED; memset( &(pBytes[1]), 32, m_nLevel ); - AddBytes(mp_Sequence, nCurrentPos, pBytes, nCount); - delete[] pBytes; + AddBytes(mp_Sequence, nCurrentPos, pBytes.get(), nCount); + pBytes.reset(); nLastLineFeedPos = nCurrentPos - nCount; if (nCurrentPos == SEQUENCESIZE) nCurrentPos = writeSequence(); |