[Libreoffice-commits] core.git: vcl/source
Mark Page
aptitude at btconnect.com
Wed Nov 30 22:01:48 UTC 2016
vcl/source/filter/igif/gifread.cxx | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
New commits:
commit 5de4492eeedc1e23f5f6ac4a775e943c240dced2
Author: Mark Page <aptitude at btconnect.com>
Date: Wed Nov 30 09:27:13 2016 +0000
Use smart pointers for allocated objects in the gif loader
Change-Id: Ib9d3bc05fbccc882df8913d3ffcb36be6a9f06dd
Reviewed-on: https://gerrit.libreoffice.org/31401
Reviewed-by: Michael Stahl <mstahl at redhat.com>
Tested-by: Michael Stahl <mstahl at redhat.com>
diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx
index f767f3b..7588970 100644
--- a/vcl/source/filter/igif/gifread.cxx
+++ b/vcl/source/filter/igif/gifread.cxx
@@ -20,6 +20,7 @@
#include "decode.hxx"
#include "gifread.hxx"
#include <memory>
+#include <o3tl/make_unique.hxx>
#define NO_PENDING( rStm ) ( ( rStm ).GetError() != ERRCODE_IO_PENDING )
@@ -55,8 +56,8 @@ class GIFReader : public GraphicReader
BitmapPalette aGPalette;
BitmapPalette aLPalette;
SvStream& rIStm;
- sal_uInt8* pSrcBuf;
- GIFLZWDecompressor* pDecomp;
+ std::vector<sal_uInt8> aSrcBuf;
+ std::unique_ptr<GIFLZWDecompressor> pDecomp;
BitmapWriteAccess* pAcc8;
BitmapWriteAccess* pAcc1;
long nYAcc;
@@ -112,7 +113,6 @@ GIFReader::GIFReader( SvStream& rStm )
: aGPalette ( 256 )
, aLPalette ( 256 )
, rIStm ( rStm )
- , pDecomp ( nullptr )
, pAcc8 ( nullptr )
, pAcc1 ( nullptr )
, nYAcc ( 0 )
@@ -143,7 +143,7 @@ GIFReader::GIFReader( SvStream& rStm )
, cNonTransIndex1 ( 0 )
{
maUpperName = "SVIGIF";
- pSrcBuf = new sal_uInt8[ 256 ];
+ aSrcBuf.resize(256); // Memory buffer for ReadNextBlock
ClearImageExtensions();
}
@@ -156,8 +156,6 @@ GIFReader::~GIFReader()
if( pAcc8 )
Bitmap::ReleaseAccess( pAcc8 );
-
- delete[] pSrcBuf;
}
void GIFReader::ClearImageExtensions()
@@ -493,7 +491,7 @@ sal_uLong GIFReader::ReadNextBlock()
nRet = 2UL;
else
{
- rIStm.ReadBytes( pSrcBuf, cBlockSize );
+ rIStm.ReadBytes( aSrcBuf.data(), cBlockSize );
if( NO_PENDING( rIStm ) )
{
@@ -502,7 +500,7 @@ sal_uLong GIFReader::ReadNextBlock()
else
{
bool bEOI;
- sal_uInt8* pTarget = pDecomp->DecompressBlock( pSrcBuf, cBlockSize, nRead, bEOI );
+ sal_uInt8* pTarget = pDecomp->DecompressBlock( aSrcBuf.data(), cBlockSize, nRead, bEOI );
nRet = ( bEOI ? 3 : 1 );
@@ -771,7 +769,7 @@ bool GIFReader::ProcessGIF()
else if( NO_PENDING( rIStm ) )
{
bRead = true;
- pDecomp = new GIFLZWDecompressor( cDataSize );
+ pDecomp = o3tl::make_unique<GIFLZWDecompressor>( cDataSize );
eActAction = NEXT_BLOCK_READING;
bOverreadBlock = false;
}
@@ -802,7 +800,7 @@ bool GIFReader::ProcessGIF()
{
if( nRet == 2UL )
{
- delete pDecomp;
+ pDecomp.reset();
CreateNewBitmaps();
eActAction = MARKER_READING;
ClearImageExtensions();
@@ -814,7 +812,7 @@ bool GIFReader::ProcessGIF()
}
else
{
- delete pDecomp;
+ pDecomp.reset();
CreateNewBitmaps();
eActAction = ABORT_READING;
ClearImageExtensions();
More information about the Libreoffice-commits
mailing list