Fix memory leak (as observed with CppunitTest_filter_pcx_test)
Change-Id: Ic00653cad7f15f60a8f2613938def25820d7e9ae
This commit is contained in:
@@ -32,7 +32,6 @@ private:
|
|||||||
SvStream& m_rPCX; // the PCX file to read
|
SvStream& m_rPCX; // the PCX file to read
|
||||||
|
|
||||||
Bitmap aBmp;
|
Bitmap aBmp;
|
||||||
BitmapWriteAccess* pAcc;
|
|
||||||
sal_uInt8 nVersion; // PCX-Version
|
sal_uInt8 nVersion; // PCX-Version
|
||||||
sal_uInt8 nEncoding; // compression type
|
sal_uInt8 nEncoding; // compression type
|
||||||
sal_uLong nBitsPerPlanePix; // bits per plane per pixel
|
sal_uLong nBitsPerPlanePix; // bits per plane per pixel
|
||||||
@@ -48,7 +47,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
bool Callback( sal_uInt16 nPercent );
|
bool Callback( sal_uInt16 nPercent );
|
||||||
void ImplReadBody();
|
void ImplReadBody(BitmapWriteAccess * pAcc);
|
||||||
void ImplReadPalette( sal_uLong nCol );
|
void ImplReadPalette( sal_uLong nCol );
|
||||||
void ImplReadHeader();
|
void ImplReadHeader();
|
||||||
|
|
||||||
@@ -63,7 +62,6 @@ public:
|
|||||||
|
|
||||||
PCXReader::PCXReader(SvStream &rStream)
|
PCXReader::PCXReader(SvStream &rStream)
|
||||||
: m_rPCX(rStream)
|
: m_rPCX(rStream)
|
||||||
, pAcc(NULL)
|
|
||||||
, nVersion(0)
|
, nVersion(0)
|
||||||
, nEncoding(0)
|
, nEncoding(0)
|
||||||
, nBitsPerPlanePix(0)
|
, nBitsPerPlanePix(0)
|
||||||
@@ -112,7 +110,8 @@ bool PCXReader::ReadPCX(Graphic & rGraphic)
|
|||||||
if ( nStatus )
|
if ( nStatus )
|
||||||
{
|
{
|
||||||
aBmp = Bitmap( Size( nWidth, nHeight ), nDestBitsPerPixel );
|
aBmp = Bitmap( Size( nWidth, nHeight ), nDestBitsPerPixel );
|
||||||
if ( ( pAcc = aBmp.AcquireWriteAccess() ) == 0 )
|
Bitmap::ScopedWriteAccess pAcc(aBmp);
|
||||||
|
if ( pAcc == 0 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( nDestBitsPerPixel <= 8 )
|
if ( nDestBitsPerPixel <= 8 )
|
||||||
@@ -126,7 +125,7 @@ bool PCXReader::ReadPCX(Graphic & rGraphic)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// read bitmap data
|
// read bitmap data
|
||||||
ImplReadBody();
|
ImplReadBody(pAcc.get());
|
||||||
|
|
||||||
// If an extended color palette exists at the end of the file, then read it and
|
// If an extended color palette exists at the end of the file, then read it and
|
||||||
// and write again in palette:
|
// and write again in palette:
|
||||||
@@ -148,9 +147,8 @@ bool PCXReader::ReadPCX(Graphic & rGraphic)
|
|||||||
rBitmap.SetPrefMapMode(aMapMode);
|
rBitmap.SetPrefMapMode(aMapMode);
|
||||||
rBitmap.SetPrefSize(Size(nWidth,nHeight));
|
rBitmap.SetPrefSize(Size(nWidth,nHeight));
|
||||||
}
|
}
|
||||||
*/ if ( nStatus && pAcc )
|
*/ if ( nStatus )
|
||||||
{
|
{
|
||||||
aBmp.ReleaseAccess( pAcc ), pAcc = NULL;
|
|
||||||
rGraphic = aBmp;
|
rGraphic = aBmp;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -217,7 +215,7 @@ void PCXReader::ImplReadHeader()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCXReader::ImplReadBody()
|
void PCXReader::ImplReadBody(BitmapWriteAccess * pAcc)
|
||||||
{
|
{
|
||||||
sal_uInt8 *pPlane[ 4 ], * pDest, * pSource1, * pSource2, * pSource3, *pSource4;
|
sal_uInt8 *pPlane[ 4 ], * pDest, * pSource1, * pSource2, * pSource3, *pSource4;
|
||||||
sal_uLong i, nx, ny, np, nCount, nPercent;
|
sal_uLong i, nx, ny, np, nCount, nPercent;
|
||||||
|
Reference in New Issue
Block a user