[Libreoffice-commits] core.git: 6 commits - oox/source registry/source sfx2/source sw/source vcl/source

Markus Mohrhard markus.mohrhard at googlemail.com
Thu Sep 5 06:45:52 PDT 2013


 oox/source/shape/ShapeContextHandler.cxx |   10 +++++-----
 registry/source/regimpl.cxx              |    1 +
 sfx2/source/doc/printhelper.cxx          |    7 ++++---
 sw/source/ui/envelp/label1.cxx           |    2 ++
 vcl/source/gdi/pdfwriter_impl.cxx        |   24 ++++++++++++------------
 5 files changed, 24 insertions(+), 20 deletions(-)

New commits:
commit 28471f774b1fdca4f02e90064209f5b16f143aa4
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Sep 5 15:37:52 2013 +0200

    CID#705713: fix memory leak
    
    Change-Id: Ic157c57fcf3fd30fe46c8c09098d532fef9cd4b2

diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx
index 918d1ca..603331c 100644
--- a/sfx2/source/doc/printhelper.cxx
+++ b/sfx2/source/doc/printhelper.cxx
@@ -680,7 +680,8 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >&
                 // of the URL. The URL we save for later using separately.
                 // Execution of the print job will be done later by executing
                 // a slot ...
-                pUCBPrintTempFile = new ::utl::TempFile();
+                if(!pUCBPrintTempFile)
+                    pUCBPrintTempFile = new ::utl::TempFile();
                 pUCBPrintTempFile->EnableKillingFile();
 
                 //FIXME: does it work?
@@ -772,7 +773,7 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >&
     //  a) printing finished                        => move the file directly and forget the watcher thread
     //  b) printing is asynchron and runs currently => start watcher thread and exit this method
     //                                                 This thread make all necessary things by itself.
-    if (pUCBPrintTempFile!=NULL)
+    if (pUCBPrintTempFile)
     {
         // a)
         SfxPrinter* pPrinter = pView->GetPrinter();
@@ -782,7 +783,7 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >&
         else
         {
             // Note: we create(d) some resource on the heap. (thread and tep file)
-            // They will be delected by the thread automaticly if he finish his run() method.
+            // They will be deleted by the thread automaticly if he finish his run() method.
             ImplUCBPrintWatcher* pWatcher = new ImplUCBPrintWatcher( pPrinter, pUCBPrintTempFile, sUcbUrl );
             pWatcher->create();
         }
commit 33f400da4a78cbbc40fe20beedad5a7ca756cfbe
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Sep 5 15:30:52 2013 +0200

    CID#705762: fix memory leak
    
    Change-Id: I0602b158bb259e27915a46485cdeac471ba6cdf2

diff --git a/sw/source/ui/envelp/label1.cxx b/sw/source/ui/envelp/label1.cxx
index ef4f774..41ec290 100644
--- a/sw/source/ui/envelp/label1.cxx
+++ b/sw/source/ui/envelp/label1.cxx
@@ -153,6 +153,8 @@ SwLabDlg::SwLabDlg(Window* pParent, const SfxItemSet& rSet,
 
     if (!bDouble)
         pRecs->insert( pRecs->begin(), pRec );
+    else
+        delete pRec;
 
     sal_uInt16 nLstGroup = 0;
     const std::vector<OUString>& rMan = aLabelsCfg.GetManufacturers();
commit a8986c2c6537116ae834fcbee12b1f1a0a418590
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Sep 5 15:28:17 2013 +0200

    CID#736586: fix memory leaks
    
    Change-Id: I02a10b8b0d18334ce693d0cead0b81d34b4eeeac

diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index d2d3e7e..9b720c2 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -73,6 +73,8 @@
 
 #include "cppuhelper/implbase1.hxx"
 
+#include <boost/scoped_array.hpp>
+
 #if !defined(ANDROID) && !defined(IOS)
 // NSS header files for PDF signing support
 #include "nss.h"
@@ -6003,26 +6005,24 @@ bool PDFWriterImpl::finalizeSignature()
 
     HASH_Begin(hc.get());
 
-    char *buffer = new char[m_nSignatureContentOffset + 1];
+    boost::scoped_array<char> buffer(new char[m_nSignatureContentOffset + 1]);
     sal_uInt64 bytesRead;
 
     //FIXME: Check if SHA1 is calculated from the correct byterange
 
-    CHECK_RETURN( (osl_File_E_None == osl_readFile( m_aFile, buffer, m_nSignatureContentOffset - 1 , &bytesRead ) ) );
+    CHECK_RETURN( (osl_File_E_None == osl_readFile( m_aFile, buffer.get(), m_nSignatureContentOffset - 1 , &bytesRead ) ) );
     if (bytesRead != (sal_uInt64)m_nSignatureContentOffset - 1)
         SAL_WARN("vcl.gdi", "PDF Signing: First buffer read failed!");
 
-    HASH_Update(hc.get(), reinterpret_cast<const unsigned char*>(buffer), bytesRead);
-    delete[] buffer;
+    HASH_Update(hc.get(), reinterpret_cast<const unsigned char*>(buffer.get()), bytesRead);
 
     CHECK_RETURN( (osl_File_E_None == osl_setFilePos( m_aFile, osl_Pos_Absolut, m_nSignatureContentOffset + MAX_SIGNATURE_CONTENT_LENGTH + 1) ) );
-    buffer = new char[nLastByteRangeNo + 1];
-    CHECK_RETURN( (osl_File_E_None == osl_readFile( m_aFile, buffer, nLastByteRangeNo, &bytesRead ) ) );
+    buffer.reset(new char[nLastByteRangeNo + 1]);
+    CHECK_RETURN( (osl_File_E_None == osl_readFile( m_aFile, buffer.get(), nLastByteRangeNo, &bytesRead ) ) );
     if (bytesRead != (sal_uInt64) nLastByteRangeNo)
         SAL_WARN("vcl.gdi", "PDF Signing: Second buffer read failed!");
 
-    HASH_Update(hc.get(), reinterpret_cast<const unsigned char*>(buffer), bytesRead);
-    delete[] buffer;
+    HASH_Update(hc.get(), reinterpret_cast<const unsigned char*>(buffer.get()), bytesRead);
 
     SECItem digest;
     unsigned char hash[SHA1_LENGTH];
commit d73c039fa5353f0b96026bed4a0da31d9a41d2c7
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Sep 5 15:17:08 2013 +0200

    CID#1078782: fix memory leak
    
    Change-Id: I4a98e68b5f74de787e28925e2e55de96f1cb980e

diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 57237b7..d2d3e7e 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -5993,7 +5993,7 @@ bool PDFWriterImpl::finalizeSignature()
     // Prepare buffer and calculate PDF file digest
     CHECK_RETURN( (osl_File_E_None == osl_setFilePos( m_aFile, osl_Pos_Absolut, 0) ) );
 
-    HASHContext *hc = HASH_Create(HASH_AlgSHA1);
+    boost::scoped_ptr<HASHContext> hc(HASH_Create(HASH_AlgSHA1));
 
     if (!hc)
     {
@@ -6001,7 +6001,7 @@ bool PDFWriterImpl::finalizeSignature()
         return false;
     }
 
-    HASH_Begin(hc);
+    HASH_Begin(hc.get());
 
     char *buffer = new char[m_nSignatureContentOffset + 1];
     sal_uInt64 bytesRead;
@@ -6012,7 +6012,7 @@ bool PDFWriterImpl::finalizeSignature()
     if (bytesRead != (sal_uInt64)m_nSignatureContentOffset - 1)
         SAL_WARN("vcl.gdi", "PDF Signing: First buffer read failed!");
 
-    HASH_Update(hc, reinterpret_cast<const unsigned char*>(buffer), bytesRead);
+    HASH_Update(hc.get(), reinterpret_cast<const unsigned char*>(buffer), bytesRead);
     delete[] buffer;
 
     CHECK_RETURN( (osl_File_E_None == osl_setFilePos( m_aFile, osl_Pos_Absolut, m_nSignatureContentOffset + MAX_SIGNATURE_CONTENT_LENGTH + 1) ) );
@@ -6021,14 +6021,14 @@ bool PDFWriterImpl::finalizeSignature()
     if (bytesRead != (sal_uInt64) nLastByteRangeNo)
         SAL_WARN("vcl.gdi", "PDF Signing: Second buffer read failed!");
 
-    HASH_Update(hc, reinterpret_cast<const unsigned char*>(buffer), bytesRead);
+    HASH_Update(hc.get(), reinterpret_cast<const unsigned char*>(buffer), bytesRead);
     delete[] buffer;
 
     SECItem digest;
     unsigned char hash[SHA1_LENGTH];
     digest.data = hash;
-    HASH_End(hc, digest.data, &digest.len, SHA1_LENGTH);
-    HASH_Destroy(hc);
+    HASH_End(hc.get(), digest.data, &digest.len, SHA1_LENGTH);
+    HASH_Destroy(hc.get());
 
     const char *pass = OUStringToOString( m_aContext.SignPassword, RTL_TEXTENCODING_UTF8 ).getStr();
 
commit faf66519cf92d7998a29b31a93d49780b8dfa28e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Sep 5 15:08:57 2013 +0200

    CID#1078783: fix memory leak
    
    Change-Id: I63a244ececcdaba5837b028bc73cbd26e8555aa4

diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 42d3a72..5ef8cbe 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -1632,6 +1632,7 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_
                     fprintf(
                         stdout, "%lu = \"%s\"\n",
                         sal::static_int_cast< unsigned long >(i), pValue);
+                    rtl_freeMemory(pValue);
                     offset += sLen;
                 }
             }
commit e340b88484905600d10ef553b4ee077278e5be0b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Sep 5 15:05:41 2013 +0200

    CID#1078784 and CID#1078785 fix memory leaks
    
    Change-Id: I5a878bfb0a6947616b1d0bfaad2541bb46903676

diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx
index 179c10a..3f601b3 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -95,7 +95,7 @@ ShapeContextHandler::getGraphicShapeContext(::sal_Int32 Element )
 {
     if (! mxGraphicShapeContext.is())
     {
-        ContextHandler2Helper *rFragmentHandler
+        boost::shared_ptr<ContextHandler2Helper> pFragmentHandler
             (new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
         ShapePtr pMasterShape;
 
@@ -104,12 +104,12 @@ ShapeContextHandler::getGraphicShapeContext(::sal_Int32 Element )
             case XML_graphic:
                 mpShape.reset(new Shape("com.sun.star.drawing.GraphicObjectShape" ));
                 mxGraphicShapeContext.set
-                (new GraphicalObjectFrameContext(*rFragmentHandler, pMasterShape, mpShape, true));
+                (new GraphicalObjectFrameContext(*pFragmentHandler, pMasterShape, mpShape, true));
                 break;
             case XML_pic:
                 mpShape.reset(new Shape("com.sun.star.drawing.GraphicObjectShape" ));
                 mxGraphicShapeContext.set
-                (new GraphicShapeContext(*rFragmentHandler, pMasterShape, mpShape));
+                (new GraphicShapeContext(*pFragmentHandler, pMasterShape, mpShape));
                 break;
             default:
                 break;
@@ -139,9 +139,9 @@ ShapeContextHandler::getDiagramShapeContext()
 {
     if (!mxDiagramShapeContext.is())
     {
-        ContextHandler2Helper *rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
+        boost::shared_ptr<ContextHandler2Helper> pFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
         mpShape.reset(new Shape());
-        mxDiagramShapeContext.set(new DiagramGraphicDataContext(*rFragmentHandler, mpShape));
+        mxDiagramShapeContext.set(new DiagramGraphicDataContext(*pFragmentHandler, mpShape));
     }
 
     return mxDiagramShapeContext;


More information about the Libreoffice-commits mailing list