[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - vcl/source

Caolán McNamara caolanm at redhat.com
Mon Jan 25 01:22:22 PST 2016


 vcl/source/filter/igif/gifread.cxx |   29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

New commits:
commit 85918431993fe3637145cca62b133c0c21cb5430
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jan 21 09:54:29 2016 +0000

    valgrind: memleak on thrown exception
    
    (cherry picked from commit 15b1080e624447ca1af1396023bb1fbfdb44fb26)
    
    Change-Id: If562dc69290021f898feff9f8e3983b867075172
    Reviewed-on: https://gerrit.libreoffice.org/21736
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: David Tardon <dtardon at redhat.com>

diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx
index 3526a0b..1e8daf9 100644
--- a/vcl/source/filter/igif/gifread.cxx
+++ b/vcl/source/filter/igif/gifread.cxx
@@ -804,33 +804,30 @@ ReadState GIFReader::ReadGIF( Graphic& rGraphic )
 
 bool ImportGIF( SvStream & rStm, Graphic& rGraphic )
 {
-    GIFReader*  pGIFReader = static_cast<GIFReader*>(rGraphic.GetContext());
-    SvStreamEndian nOldFormat = rStm.GetEndian();
-    ReadState   eReadState;
-    bool        bRet = true;
+    std::unique_ptr<GIFReader>  xGIFReader(static_cast<GIFReader*>(rGraphic.GetContext()));
+    rGraphic.SetContext(nullptr);
 
+    SvStreamEndian nOldFormat = rStm.GetEndian();
     rStm.SetEndian( SvStreamEndian::LITTLE );
 
-    if( !pGIFReader )
-        pGIFReader = new GIFReader( rStm );
+    if (!xGIFReader)
+        xGIFReader.reset(new GIFReader(rStm));
 
-    rGraphic.SetContext( NULL );
-    eReadState = pGIFReader->ReadGIF( rGraphic );
+    bool bRet = true;
 
-    if( eReadState == GIFREAD_ERROR )
+    ReadState eReadState = xGIFReader->ReadGIF(rGraphic);
+
+    if (eReadState == GIFREAD_ERROR)
     {
         bRet = false;
-        delete pGIFReader;
     }
-    else if( eReadState == GIFREAD_OK )
-        delete pGIFReader;
-    else
+    else if (eReadState == GIFREAD_NEED_MORE)
     {
-        rGraphic = pGIFReader->GetIntermediateGraphic();
-        rGraphic.SetContext( pGIFReader );
+        rGraphic = xGIFReader->GetIntermediateGraphic();
+        rGraphic.SetContext(xGIFReader.release());
     }
 
-    rStm.SetEndian( nOldFormat );
+    rStm.SetEndian(nOldFormat);
 
     return bRet;
 }


More information about the Libreoffice-commits mailing list