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

New commits:
commit 85918431993fe3637145cca62b133c0c21cb5430
Author: Caolán McNamara <caol...@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 <c...@libreoffice.org>
    Reviewed-by: David Tardon <dtar...@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;
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to