[Libreoffice-commits] core.git: hwpfilter/source

Caolán McNamara caolanm at redhat.com
Mon Aug 28 15:05:39 UTC 2017


 hwpfilter/source/hwpread.cxx |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

New commits:
commit efa8e32389ddd1db4e7b5b88856436fdc7061733
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Aug 28 12:28:22 2017 +0100

    ofz#3160 Direct-leak
    
    Change-Id: I6dcc35aaa06c2599a4524194e5e633cd4e36474e
    Reviewed-on: https://gerrit.libreoffice.org/41634
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index 8b0c877c1f98..826272f8eb74 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -21,6 +21,7 @@
 
 #include <comphelper/newarray.hxx>
 
+#include <assert.h>
 #include <list>
 
 #include "hwpfile.h"
@@ -459,12 +460,14 @@ bool Picture::Read(HWPFile & hwpf)
 
         if (pictype == PICTYPE_DRAW)
         {
-            hmem = new HMemIODev(reinterpret_cast<char *>(follow.data()), follow_block_size);
+            HMemIODev* pOldMem = hmem;
+            HMemIODev* pNewMem = new HMemIODev(reinterpret_cast<char *>(follow.data()), follow_block_size);
+            hmem = pNewMem;
             LoadDrawingObjectBlock(this);
             style.cell = picinfo.picdraw.hdo;
-            delete hmem;
-
-            hmem = nullptr;
+            assert(hmem == pNewMem);
+            delete pNewMem;
+            hmem = pOldMem;
         }
         else if (follow_block_size >= 4)
         {


More information about the Libreoffice-commits mailing list