diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-04-03 13:28:47 +0900 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-04-04 07:20:50 -0500 |
commit | 4da62012fea1796c1fed5bb2d87a353d1be79ea5 (patch) | |
tree | 9c8f804098507a8c8e7af53e11654f824ad5a08e /extensions | |
parent | Drop dead code since 2002 (diff) | |
download | core-4da62012fea1796c1fed5bb2d87a353d1be79ea5.tar.gz core-4da62012fea1796c1fed5bb2d87a353d1be79ea5.zip |
Fix a memory leak by freeing last pBytes
Change-Id: I7d170d704fa8950057698856d12df63992e38381
Reviewed-on: https://gerrit.libreoffice.org/8822
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/plugin/base/nfuncs.cxx | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/extensions/source/plugin/base/nfuncs.cxx b/extensions/source/plugin/base/nfuncs.cxx index d56e02a9b7f5..796a4a1f03ac 100644 --- a/extensions/source/plugin/base/nfuncs.cxx +++ b/extensions/source/plugin/base/nfuncs.cxx @@ -44,6 +44,7 @@ #include <plugin/impl.hxx> #include <vcl/svapp.hxx> +#include <boost/scoped_array.hpp> #if OSL_DEBUG_LEVEL > 1 #include <osl/thread.h> @@ -425,20 +426,19 @@ extern "C" { return NPERR_FILE_NOT_FOUND; PluginInputStream* pInputStream = (PluginInputStream*)pStream; - sal_Int8* pBytes = NULL; + boost::scoped_array<sal_Int8> pBytes; int nBytes = 0; pPlugin->enterPluginCallback(); while( rangeList ) { if( pBytes && nBytes < (int)rangeList->length ) - { - delete [] pBytes; - pBytes = NULL; + pBytes.reset(); + if( ! pBytes ) { + nBytes = rangeList->length; + pBytes.reset(new sal_Int8[ nBytes ]); } - if( ! pBytes ) - pBytes = new sal_Int8[ nBytes = rangeList->length ]; int nRead = - pInputStream->read( rangeList->offset, pBytes, rangeList->length ); + pInputStream->read( rangeList->offset, pBytes.get(), rangeList->length ); int nPos = 0; int nNow; do @@ -451,7 +451,7 @@ extern "C" { stream, rangeList->offset + nPos, nNow, - pBytes+nPos ); + pBytes.get()+nPos ); nPos += nNow; nRead -= nNow; } while( nRead > 0 && nNow ); |