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>
This commit is contained in:
committed by
Caolán McNamara
parent
eaf260871e
commit
4da62012fe
@@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#include <plugin/impl.hxx>
|
#include <plugin/impl.hxx>
|
||||||
#include <vcl/svapp.hxx>
|
#include <vcl/svapp.hxx>
|
||||||
|
#include <boost/scoped_array.hpp>
|
||||||
|
|
||||||
#if OSL_DEBUG_LEVEL > 1
|
#if OSL_DEBUG_LEVEL > 1
|
||||||
#include <osl/thread.h>
|
#include <osl/thread.h>
|
||||||
@@ -425,20 +426,19 @@ extern "C" {
|
|||||||
return NPERR_FILE_NOT_FOUND;
|
return NPERR_FILE_NOT_FOUND;
|
||||||
|
|
||||||
PluginInputStream* pInputStream = (PluginInputStream*)pStream;
|
PluginInputStream* pInputStream = (PluginInputStream*)pStream;
|
||||||
sal_Int8* pBytes = NULL;
|
boost::scoped_array<sal_Int8> pBytes;
|
||||||
int nBytes = 0;
|
int nBytes = 0;
|
||||||
pPlugin->enterPluginCallback();
|
pPlugin->enterPluginCallback();
|
||||||
while( rangeList )
|
while( rangeList )
|
||||||
{
|
{
|
||||||
if( pBytes && nBytes < (int)rangeList->length )
|
if( pBytes && nBytes < (int)rangeList->length )
|
||||||
{
|
pBytes.reset();
|
||||||
delete [] pBytes;
|
if( ! pBytes ) {
|
||||||
pBytes = NULL;
|
nBytes = rangeList->length;
|
||||||
|
pBytes.reset(new sal_Int8[ nBytes ]);
|
||||||
}
|
}
|
||||||
if( ! pBytes )
|
|
||||||
pBytes = new sal_Int8[ nBytes = rangeList->length ];
|
|
||||||
int nRead =
|
int nRead =
|
||||||
pInputStream->read( rangeList->offset, pBytes, rangeList->length );
|
pInputStream->read( rangeList->offset, pBytes.get(), rangeList->length );
|
||||||
int nPos = 0;
|
int nPos = 0;
|
||||||
int nNow;
|
int nNow;
|
||||||
do
|
do
|
||||||
@@ -451,7 +451,7 @@ extern "C" {
|
|||||||
stream,
|
stream,
|
||||||
rangeList->offset + nPos,
|
rangeList->offset + nPos,
|
||||||
nNow,
|
nNow,
|
||||||
pBytes+nPos );
|
pBytes.get()+nPos );
|
||||||
nPos += nNow;
|
nPos += nNow;
|
||||||
nRead -= nNow;
|
nRead -= nNow;
|
||||||
} while( nRead > 0 && nNow );
|
} while( nRead > 0 && nNow );
|
||||||
|
Reference in New Issue
Block a user