diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-05-27 11:12:37 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-05-27 11:13:32 +0200 |
commit | c77c39056847d23a109172ff53bfac0ba4c21b39 (patch) | |
tree | 57c970ef7bb998faf1f3be838e8e5df11b3e238e /filter | |
parent | 76032655c3a2c763e27f5fb57da4b1214c284aab (diff) |
Fix memory leak (as observed with CppunitTest_filter_pcx_test)
Change-Id: Ic00653cad7f15f60a8f2613938def25820d7e9ae
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/graphicfilter/ipcx/ipcx.cxx | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/filter/source/graphicfilter/ipcx/ipcx.cxx b/filter/source/graphicfilter/ipcx/ipcx.cxx index 2d941b85dd02..32dc0d936ef7 100644 --- a/filter/source/graphicfilter/ipcx/ipcx.cxx +++ b/filter/source/graphicfilter/ipcx/ipcx.cxx @@ -32,7 +32,6 @@ private: SvStream& m_rPCX; // the PCX file to read Bitmap aBmp; - BitmapWriteAccess* pAcc; sal_uInt8 nVersion; // PCX-Version sal_uInt8 nEncoding; // compression type sal_uLong nBitsPerPlanePix; // bits per plane per pixel @@ -48,7 +47,7 @@ private: bool Callback( sal_uInt16 nPercent ); - void ImplReadBody(); + void ImplReadBody(BitmapWriteAccess * pAcc); void ImplReadPalette( sal_uLong nCol ); void ImplReadHeader(); @@ -63,7 +62,6 @@ public: PCXReader::PCXReader(SvStream &rStream) : m_rPCX(rStream) - , pAcc(NULL) , nVersion(0) , nEncoding(0) , nBitsPerPlanePix(0) @@ -112,7 +110,8 @@ bool PCXReader::ReadPCX(Graphic & rGraphic) if ( nStatus ) { aBmp = Bitmap( Size( nWidth, nHeight ), nDestBitsPerPixel ); - if ( ( pAcc = aBmp.AcquireWriteAccess() ) == 0 ) + Bitmap::ScopedWriteAccess pAcc(aBmp); + if ( pAcc == 0 ) return false; if ( nDestBitsPerPixel <= 8 ) @@ -126,7 +125,7 @@ bool PCXReader::ReadPCX(Graphic & rGraphic) } } // read bitmap data - ImplReadBody(); + ImplReadBody(pAcc.get()); // If an extended color palette exists at the end of the file, then read it and // and write again in palette: @@ -148,9 +147,8 @@ bool PCXReader::ReadPCX(Graphic & rGraphic) rBitmap.SetPrefMapMode(aMapMode); rBitmap.SetPrefSize(Size(nWidth,nHeight)); } - */ if ( nStatus && pAcc ) + */ if ( nStatus ) { - aBmp.ReleaseAccess( pAcc ), pAcc = NULL; rGraphic = aBmp; 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_uLong i, nx, ny, np, nCount, nPercent; |