[Libreoffice-commits] core.git: 7 commits - connectivity/qa connectivity/source cppcanvas/qa filter/source vcl/source

Stephan Bergmann sbergman at redhat.com
Fri May 30 06:55:30 PDT 2014


 connectivity/qa/connectivity/mork/DriverTest.cxx        |    7 +++
 connectivity/source/drivers/mork/MNSProfileDiscover.cxx |    8 +---
 connectivity/source/drivers/mork/MNSProfileDiscover.hxx |   15 ++------
 connectivity/source/drivers/mork/MQueryHelper.cxx       |   16 +-------
 connectivity/source/drivers/mork/MQueryHelper.hxx       |   29 +++++++++-------
 connectivity/source/drivers/mork/MResultSet.cxx         |   20 ++++-------
 connectivity/source/drivers/mork/MResultSet.hxx         |    1 
 cppcanvas/qa/unit/test.cxx                              |    6 ++-
 filter/source/xsltfilter/LibXSLTTransformer.cxx         |    1 
 vcl/source/gdi/impfont.cxx                              |    2 -
 10 files changed, 50 insertions(+), 55 deletions(-)

New commits:
commit 5409e6a126b0bc9e6ba3bb348e431bdfc32219f4
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri May 30 15:54:30 2014 +0200

    Avoid undefined left shift of negative integer
    
    Change-Id: Ib857f7c802b4ce65ec352b67e6acde59965c893a

diff --git a/vcl/source/gdi/impfont.cxx b/vcl/source/gdi/impfont.cxx
index eb5a0c0..25beddc 100644
--- a/vcl/source/gdi/impfont.cxx
+++ b/vcl/source/gdi/impfont.cxx
@@ -282,7 +282,7 @@ sal_UCS4 ImplFontCharMap::GetCharFromIndex( int nCharIndex ) const
 
 static unsigned GetUInt( const unsigned char* p ) { return((p[0]<<24)+(p[1]<<16)+(p[2]<<8)+p[3]);}
 static unsigned Getsal_uInt16( const unsigned char* p ){ return((p[0]<<8) | p[1]);}
-static int GetSShort( const unsigned char* p ){ return((static_cast<signed char>(p[0])<<8)|p[1]);}
+static int GetSShort( const unsigned char* p ){ return static_cast<sal_Int16>((p[0]<<8)|p[1]);}
 
 // TODO: move CMAP parsing directly into the ImplFontCharMap class
 bool ParseCMAP( const unsigned char* pCmap, int nLength, CmapResult& rResult )
commit bb78022488ef283441c4f04cb357d7b5594348a2
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri May 30 15:53:00 2014 +0200

    Fix memory leak in test code
    
    Change-Id: I318878b3fa883eebbc081a6faf6a594dad2c6e26

diff --git a/cppcanvas/qa/unit/test.cxx b/cppcanvas/qa/unit/test.cxx
index af652a3..06d8d6e 100644
--- a/cppcanvas/qa/unit/test.cxx
+++ b/cppcanvas/qa/unit/test.cxx
@@ -7,6 +7,9 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include <sal/config.h>
+
+#include <boost/scoped_ptr.hpp>
 #include <test/bootstrapfixture.hxx>
 
 #include <osl/file.hxx>
@@ -40,8 +43,7 @@ public:
 void CanvasTest::testComposite()
 {
 #ifdef LINUX
-    Window* pWin = new WorkWindow( (Window *)NULL );
-    CPPUNIT_ASSERT( pWin != NULL );
+    boost::scoped_ptr<Window> pWin(new WorkWindow( (Window *)NULL ));
 
     uno::Reference<rendering::XCanvas> xCanvas = pWin->GetCanvas ();
     if( !xCanvas.is() )
commit aaaf4c4332bbe88841d855facefe38227b9be590
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri May 30 15:52:07 2014 +0200

    Fix leak
    
    Change-Id: Ie1c0cb94fae8b227f7ef66df5a2a2ca3f0738897

diff --git a/filter/source/xsltfilter/LibXSLTTransformer.cxx b/filter/source/xsltfilter/LibXSLTTransformer.cxx
index 82ac99f..882501f 100644
--- a/filter/source/xsltfilter/LibXSLTTransformer.cxx
+++ b/filter/source/xsltfilter/LibXSLTTransformer.cxx
@@ -327,6 +327,7 @@ namespace XSLT
                 outBuf->writecallback = &ParserOutputBufferCallback::on_write;
                 outBuf->closecallback = &ParserOutputBufferCallback::on_close;
                 xsltSaveResultTo(outBuf, result, styleSheet);
+                xmlOutputBufferClose(outBuf);
             }
         else
             {
commit f33dc92572ecee77437dc5aa4742a5384c86cf71
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri May 30 15:49:32 2014 +0200

    Fix memory leak
    
    Change-Id: Ia9176826b89b947408230bf65db26a83f269c845

diff --git a/connectivity/source/drivers/mork/MQueryHelper.cxx b/connectivity/source/drivers/mork/MQueryHelper.cxx
index c06cb9b..ff1d14e 100644
--- a/connectivity/source/drivers/mork/MQueryHelper.cxx
+++ b/connectivity/source/drivers/mork/MQueryHelper.cxx
@@ -97,16 +97,6 @@ void MQueryHelper::setAddressbook(OUString &ab)
     OSL_TRACE("\tOUT MQuery::setAddressbook()");
 }
 
-void MQueryHelper::setExpression( MQueryExpression &_expr )
-{
-    OSL_TRACE("IN MQueryHelper::setExpression()");
-    ::osl::MutexGuard aGuard(m_aMutex);
-
-    m_aExpr = _expr;
-
-    OSL_TRACE("\tOUT MQuery::setExpression()");
-}
-
 void MQueryHelper::append(MQueryHelperResultEntry* resEnt)
 {
     if ( resEnt != NULL ) {
@@ -198,7 +188,7 @@ bool MQueryHelper::getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const OUS
     return true;
 }
 
-sal_Int32 MQueryHelper::executeQuery(OConnection* xConnection)
+sal_Int32 MQueryHelper::executeQuery(OConnection* xConnection, MQueryExpression & expr)
 {
     reset();
 
@@ -256,7 +246,7 @@ sal_Int32 MQueryHelper::executeQuery(OConnection* xConnection)
                     OUString valueOUString = OStringToOUString( valueOString, RTL_TEXTENCODING_UTF8 );
                     entry->setValue(key, valueOUString);
                 }
-                ::std::vector< sal_Bool > vector = entryMatchedByExpression(this, &m_aExpr, entry);
+                ::std::vector< sal_Bool > vector = entryMatchedByExpression(this, &expr, entry);
                 bool result = true;
                 for (::std::vector<sal_Bool>::iterator iter = vector.begin(); iter != vector.end(); ++iter)
                 {
@@ -279,7 +269,7 @@ sal_Int32 MQueryHelper::executeQuery(OConnection* xConnection)
 ::std::vector< sal_Bool > entryMatchedByExpression(MQueryHelper* _aQuery, MQueryExpression* _aExpr, MQueryHelperResultEntry* entry)
 {
     ::std::vector< sal_Bool > resultVector;
-    MQueryExpression::ExprVector::iterator evIter;
+    MQueryExpression::ExprVector::const_iterator evIter;
     for( evIter = _aExpr->getExpressions().begin();
          evIter != _aExpr->getExpressions().end();
          ++evIter )
diff --git a/connectivity/source/drivers/mork/MQueryHelper.hxx b/connectivity/source/drivers/mork/MQueryHelper.hxx
index 590b275..204fdb6 100644
--- a/connectivity/source/drivers/mork/MQueryHelper.hxx
+++ b/connectivity/source/drivers/mork/MQueryHelper.hxx
@@ -27,6 +27,7 @@
 #include <osl/thread.hxx>
 #include <connectivity/FValue.hxx>
 
+#include <boost/noncopyable.hpp>
 #include <boost/unordered_map.hpp>
 
 #include "MErrorResource.hxx"
@@ -68,6 +69,8 @@ namespace connectivity
             MQueryExpressionBase( node_type _eNodeType ) : m_eNodeType( _eNodeType ) {}
 
         public:
+            virtual ~MQueryExpressionBase() {}
+
             bool   isUnknown( ) const { return m_eNodeType == Unknown; }
             bool   isStringExpr( ) const { return m_eNodeType == StringExpr; }
             bool   isExpr( ) const { return m_eNodeType == Expr; }
@@ -105,7 +108,7 @@ namespace connectivity
             const OUString&    getValue() const { return m_aValue; }
         };
 
-        class MQueryExpression : public MQueryExpressionBase
+        class MQueryExpression : public MQueryExpressionBase, private boost::noncopyable
         {
             friend class MQueryHelper;
 
@@ -117,14 +120,14 @@ namespace connectivity
                 OR
             } bool_cond;
 
-            void setExpressions( ExprVector& _exprVector )
-                            { m_aExprVector = _exprVector; }
-
             // All expressions on a peer level use same condition operator
             void setExpressionCondition( bool_cond _cond )
                             { m_aExprCondType = _cond; }
 
-            ExprVector& getExpressions( )
+            void addExpression(MQueryExpressionBase * expr)
+                            { m_aExprVector.push_back(expr); }
+
+            ExprVector const & getExpressions( ) const
                             { return m_aExprVector; }
 
             // All expressions on a peer level use same condition operator
@@ -133,8 +136,15 @@ namespace connectivity
 
             MQueryExpression() : MQueryExpressionBase( MQueryExpressionBase::Expr ),
                                  m_aExprCondType( OR )
-                            { m_aExprVector.clear(); }
-
+                            {}
+
+            virtual ~MQueryExpression() {
+                for (ExprVector::iterator i(m_aExprVector.begin());
+                     i != m_aExprVector.end(); ++i)
+                {
+                    delete *i;
+                }
+            }
 
         protected:
             ExprVector          m_aExprVector;
@@ -174,7 +184,6 @@ namespace connectivity
             OColumnAlias        m_rColumnAlias;
             ErrorDescriptor     m_aError;
             OUString     m_aAddressbook;
-            MQueryExpression    m_aExpr;
 
 /*
             void            clearResultOrComplete();
@@ -197,14 +206,12 @@ namespace connectivity
             sal_Int32                  getResultCount() const;
             bool                       checkRowAvailable( sal_Int32 nDBRow );
             bool                       getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const OUString& aDBColumnName, sal_Int32 nType );
-            sal_Int32                  executeQuery(OConnection* xConnection);
+            sal_Int32                  executeQuery(OConnection* xConnection, MQueryExpression & expr);
             const OColumnAlias&        getColumnAlias() const { return m_rColumnAlias; }
             bool                       hadError() const { return m_aError.is(); }
             inline ErrorDescriptor&    getError() { return m_aError; }
 
             void                       setAddressbook( OUString&);
-            void                       setExpression( MQueryExpression &_expr );
-
         };
     }
 }
diff --git a/connectivity/source/drivers/mork/MResultSet.cxx b/connectivity/source/drivers/mork/MResultSet.cxx
index 95aa7d5..8b1de56 100644
--- a/connectivity/source/drivers/mork/MResultSet.cxx
+++ b/connectivity/source/drivers/mork/MResultSet.cxx
@@ -823,7 +823,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode*                 parseT
         OSL_TRACE("analyseSQL : Got Punctuation ()");
         MQueryExpression *subExpression = new MQueryExpression();
         analyseWhereClause( parseTree->getChild( 1 ), *subExpression );
-        queryExpression.getExpressions().push_back( subExpression );
+        queryExpression.addExpression( subExpression );
     }
     else if ((SQL_ISRULE(parseTree,search_condition) || (SQL_ISRULE(parseTree,boolean_term)))
              && parseTree->count() == 3)                   // Handle AND/OR
@@ -885,7 +885,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode*                 parseT
             OSL_TRACE("Query always evaluates to FALSE");
             m_bIsAlwaysFalseQuery = true;
         }
-        queryExpression.getExpressions().push_back( new MQueryExpressionString( columnName, op, matchString ));
+        queryExpression.addExpression( new MQueryExpressionString( columnName, op, matchString ));
     }
     else if (SQL_ISRULE(parseTree,like_predicate))
     {
@@ -1021,7 +1021,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode*                 parseT
             }
         }
 
-        queryExpression.getExpressions().push_back( new MQueryExpressionString( columnName, op, matchString ));
+        queryExpression.addExpression( new MQueryExpressionString( columnName, op, matchString ));
     }
     else if (SQL_ISRULE(parseTree,test_for_null))
     {
@@ -1046,7 +1046,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode*                 parseT
         OUString sTableRange;
         m_pSQLIterator->getColumnRange(parseTree->getChild(0),columnName,sTableRange);
 
-        queryExpression.getExpressions().push_back( new MQueryExpressionString( columnName, op ));
+        queryExpression.addExpression( new MQueryExpressionString( columnName, op ));
     }
     else
     {
@@ -1103,12 +1103,10 @@ void OResultSet::fillRowData()
         return;
     }
 
-    m_aQueryHelper.setExpression( queryExpression );
-
     OUString aStr(  m_pTable->getName() );
     m_aQueryHelper.setAddressbook( aStr );
 
-    sal_Int32 rv = m_aQueryHelper.executeQuery(xConnection);
+    sal_Int32 rv = m_aQueryHelper.executeQuery(xConnection, queryExpression);
     if ( rv == -1 ) {
         m_pStatement->getOwnConnection()->throwSQLException( STR_ERR_EXECUTING_QUERY, *this );
     }
commit c9f5e9b70968ab3f6990a47f5c98e55bcc87650d
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri May 30 15:48:49 2014 +0200

    Fix memory leak
    
    Change-Id: I70522657f968ed4f84e9447dd999d8be746fc973

diff --git a/connectivity/source/drivers/mork/MResultSet.cxx b/connectivity/source/drivers/mork/MResultSet.cxx
index d88f784..95aa7d5 100644
--- a/connectivity/source/drivers/mork/MResultSet.cxx
+++ b/connectivity/source/drivers/mork/MResultSet.cxx
@@ -103,7 +103,6 @@ OResultSet::OResultSet(OCommonStatement* pStmt, const ::boost::shared_ptr< conne
     ,m_nParamIndex(0)
     ,m_bIsAlwaysFalseQuery(false)
     ,m_pKeySet(NULL)
-    ,m_pSortIndex(NULL)
     ,m_nNewRow(0)
     ,m_nUpdatedRow(0)
     ,m_RowStates(0)
@@ -1266,7 +1265,7 @@ void SAL_CALL OResultSet::executeQuery() throw( ::com::sun::star::sdbc::SQLExcep
 
                     OSL_ENSURE( m_aQueryHelper.queryComplete(), "Query not complete!!");
 
-                    m_pSortIndex = new OSortIndex(eKeyType,m_aOrderbyAscending);
+                    OSortIndex aSortIndex(eKeyType,m_aOrderbyAscending);
 
                     OSL_TRACE("OrderbyColumnNumber->size() = %zu",m_aOrderbyColumnNumber.size());
 #if OSL_DEBUG_LEVEL > 0
@@ -1287,17 +1286,16 @@ void SAL_CALL OResultSet::executeQuery() throw( ::com::sun::star::sdbc::SQLExcep
                             pKeyValue->pushKey(new ORowSetValueDecorator(value));
                         }
 
-                        m_pSortIndex->AddKeyValue( pKeyValue );
+                        aSortIndex.AddKeyValue( pKeyValue );
                     }
 
-                    m_pKeySet = m_pSortIndex->CreateKeySet();
+                    m_pKeySet = aSortIndex.CreateKeySet();
                     m_CurrentRowCount = static_cast<sal_Int32>(m_pKeySet->get().size());
 #if OSL_DEBUG_LEVEL > 0
                     for( OKeySet::Vector::size_type i = 0; i < m_pKeySet->get().size(); i++ )
                         OSL_TRACE("Sorted: %d -> %d", i, (m_pKeySet->get())[i] );
 #endif
 
-                    m_pSortIndex = NULL;
                     beforeFirst(); // Go back to start
                 }
                 else  //we always need m_pKeySet now
diff --git a/connectivity/source/drivers/mork/MResultSet.hxx b/connectivity/source/drivers/mork/MResultSet.hxx
index f6bb8dc..1126ef7 100644
--- a/connectivity/source/drivers/mork/MResultSet.hxx
+++ b/connectivity/source/drivers/mork/MResultSet.hxx
@@ -237,7 +237,6 @@ protected:
             sal_Int32                m_nParamIndex;
             bool                 m_bIsAlwaysFalseQuery;
             ::rtl::Reference<OKeySet>     m_pKeySet;
-            OSortIndex*              m_pSortIndex;
             sal_Int32                 m_nNewRow;        //inserted row
             sal_Int32                     m_nUpdatedRow;    //updated row
             sal_Int32                 m_RowStates;
commit 63405c050050b4f2ea2ba922e7031e2c0b5d3621
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri May 30 15:46:14 2014 +0200

    Fix memory leak
    
    Change-Id: I0e5c3af0504f3090a5db7692c6bfb1d33b3aa81f

diff --git a/connectivity/source/drivers/mork/MNSProfileDiscover.cxx b/connectivity/source/drivers/mork/MNSProfileDiscover.cxx
index 4b7ac55..87c064c 100644
--- a/connectivity/source/drivers/mork/MNSProfileDiscover.cxx
+++ b/connectivity/source/drivers/mork/MNSProfileDiscover.cxx
@@ -122,10 +122,9 @@ namespace connectivity
                         fullProfilePath = profilePath;
                     }
 
-                    ProfileStruct*  profileItem     = new ProfileStruct(product,profileName,
+                    m_Product.mProfileList[profileName] = ProfileStruct(product,profileName,
                             fullProfilePath
                         );
-                    m_Product.mProfileList[profileName] = profileItem;
 
                     sal_Int32 isDefault = 0;
                     if (!sIsDefault.isEmpty())
@@ -151,7 +150,7 @@ namespace connectivity
                 return OUString();
             }
             else
-                return m_Product.mProfileList[profileName]->getProfilePath();
+                return m_Product.mProfileList[profileName].getProfilePath();
         }
 
         OUString ProfileAccess::getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException)
@@ -168,8 +167,7 @@ namespace connectivity
                 //there are not any profiles
                 return OUString();
             }
-            ProfileStruct * aProfile = (*m_Product.mProfileList.begin()).second;
-            return aProfile->getProfileName();
+            return (*m_Product.mProfileList.begin()).second.getProfileName();
         }
     }
 }
diff --git a/connectivity/source/drivers/mork/MNSProfileDiscover.hxx b/connectivity/source/drivers/mork/MNSProfileDiscover.hxx
index 26a8ece..5ae5688 100644
--- a/connectivity/source/drivers/mork/MNSProfileDiscover.hxx
+++ b/connectivity/source/drivers/mork/MNSProfileDiscover.hxx
@@ -34,14 +34,7 @@
 #include "dllapi.h"
 
 using namespace com::sun::star::mozilla;
-namespace connectivity
-{
-    namespace mork
-    {
-        class ProfileStruct;
-    }
-}
-typedef ::std::map < OUString, ::connectivity::mork::ProfileStruct* > ProfileList;
+
 namespace connectivity
 {
     namespace mork
@@ -49,8 +42,8 @@ namespace connectivity
         class ProfileStruct
         {
         public:
-            ProfileStruct(MozillaProductType aProduct, const OUString& aProfileName,
-                          const OUString &aProfilePath
+            ProfileStruct(MozillaProductType aProduct = MozillaProductType_Default, const OUString& aProfileName = OUString(),
+                          const OUString &aProfilePath = OUString()
                             );
             MozillaProductType getProductType() { return product;}
             OUString getProfileName(){ return profileName;}
@@ -61,6 +54,8 @@ namespace connectivity
             OUString profilePath;
         };
 
+        typedef ::std::map < OUString, ProfileStruct > ProfileList;
+
         class ProductStruct
         {
         public:
commit 4bd5d16381442fc94b6beecd6c16dd15686be924
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri May 30 15:41:01 2014 +0200

    Fix leaks in test code
    
    Change-Id: I435fcfd6d10875565b543ea76fa8bfbf52e5f5d0

diff --git a/connectivity/qa/connectivity/mork/DriverTest.cxx b/connectivity/qa/connectivity/mork/DriverTest.cxx
index ea01649..39d45b4 100644
--- a/connectivity/qa/connectivity/mork/DriverTest.cxx
+++ b/connectivity/qa/connectivity/mork/DriverTest.cxx
@@ -97,6 +97,7 @@ void MorkDriverTest::tearDown()
 {
 // how to make dispose() work?
 // Reference< com::sun::star::lang::XComponent >( m_xMorkComponent, UNO_QUERY_THROW )->dispose();
+    m_xConnection->close();
     test::BootstrapFixture::tearDown();
 }
 
@@ -159,6 +160,9 @@ void MorkDriverTest::test_select_default_all()
     CPPUNIT_ASSERT_MESSAGE("fetch last row failed!", result);
     mail = xDelegatorRow->getString(1);
     CPPUNIT_ASSERT_MESSAGE("last row is not john at doe9.org!", mail.equalsAscii("john at doe9.org"));
+
+    css::uno::Reference<css::sdbc::XCloseable>(
+        xStatement, css::uno::UNO_QUERY_THROW)->close();
 }
 
 void MorkDriverTest::test_select_list_table_joe_doe_5()
@@ -186,6 +190,9 @@ void MorkDriverTest::test_select_list_table_joe_doe_5()
     CPPUNIT_ASSERT_MESSAGE("fetch first row failed!", result);
     OUString mail = xDelegatorRow->getString(1);
     CPPUNIT_ASSERT_MESSAGE("last row is not john at doe5.org!", mail.equalsAscii("john at doe5.org"));
+
+    css::uno::Reference<css::sdbc::XCloseable>(
+        xStatement, css::uno::UNO_QUERY_THROW)->close();
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(MorkDriverTest);


More information about the Libreoffice-commits mailing list