[Libreoffice-commits] .: 3 commits - cppuhelper/source sal/osl

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 16 08:27:22 PST 2013


 cppuhelper/source/defaultbootstrap.cxx |   17 -------
 cppuhelper/source/servicemanager.cxx   |   78 +++++++++++++++++++++------------
 cppuhelper/source/servicemanager.hxx   |   17 ++++---
 sal/osl/w32/file_dirvol.cxx            |   20 ++++++--
 4 files changed, 76 insertions(+), 56 deletions(-)

New commits:
commit 588997f0ebc5696574680098b128e66eff54f00c
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jan 16 17:19:10 2013 +0100

    fdo#58415: Don't ignore osl_getFileURLFromSystemPath failure
    
    ...in osl_getFileStatus et al, it would leave the relevant status string member
    unchanged (i.e., a null pointer) but would mark it as valid, so that later code
    to retrieve the allegedly valid string member would crash upon the null pointer.
    
    Change-Id: Ia8528f5dc27d94f3d14a2c416955a041b87863d3

diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index 484bc1b..89d286b 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -1515,8 +1515,10 @@ oslFileError SAL_CALL osl_getVolumeInformation(
 
     if (uFieldMask & osl_VolumeInfo_Mask_DeviceHandle)
     {
+        error = osl_getFileURLFromSystemPath(volume_root.pData, (rtl_uString**)&pInfo->pDeviceHandle);
+        if (error != osl_File_E_None)
+            return error;
         pInfo->uValidFields |= osl_VolumeInfo_Mask_DeviceHandle;
-        osl_getFileURLFromSystemPath(volume_root.pData, (rtl_uString**)&pInfo->pDeviceHandle);
     }
 
     return osl_File_E_None;
@@ -1612,8 +1614,10 @@ static oslFileError SAL_CALL osl_getDriveInfo(
         rtl_uString *ustrSystemPath = NULL;
 
         rtl_uString_newFromStr( &ustrSystemPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->cDriveString) );
-        osl_getFileURLFromSystemPath( ustrSystemPath, &pStatus->ustrFileURL );
+        oslFileError error = osl_getFileURLFromSystemPath( ustrSystemPath, &pStatus->ustrFileURL );
         rtl_uString_release( ustrSystemPath );
+        if (error != osl_File_E_None)
+            return error;
         pStatus->uValidFields |= osl_FileStatus_Mask_FileURL;
     }
     return osl_File_E_None;
@@ -1641,7 +1645,9 @@ static oslFileError SAL_CALL osl_getServerInfo(
 
     if ( uFieldMask & osl_FileStatus_Mask_FileURL )
     {
-        osl_getFileURLFromSystemPath( pItemImpl->m_pFullPath, &pStatus->ustrFileURL );
+        oslFileError error = osl_getFileURLFromSystemPath( pItemImpl->m_pFullPath, &pStatus->ustrFileURL );
+        if (error != osl_File_E_None)
+            return error;
         pStatus->uValidFields |= osl_FileStatus_Mask_FileURL;
     }
     return osl_File_E_None;
@@ -1730,7 +1736,9 @@ oslFileError SAL_CALL osl_getFileStatus(
 
     if ( uFieldMask & osl_FileStatus_Mask_LinkTargetURL )
     {
-        osl_getFileURLFromSystemPath( pItemImpl->m_pFullPath, &pStatus->ustrLinkTargetURL );
+        oslFileError error = osl_getFileURLFromSystemPath( pItemImpl->m_pFullPath, &pStatus->ustrLinkTargetURL );
+        if (error != osl_File_E_None)
+            return error;
 
         pStatus->uValidFields |= osl_FileStatus_Mask_LinkTargetURL;
     }
@@ -1752,7 +1760,9 @@ oslFileError SAL_CALL osl_getFileStatus(
             }
         }
 
-        osl_getFileURLFromSystemPath( pItemImpl->m_pFullPath, &pStatus->ustrFileURL );
+        oslFileError error = osl_getFileURLFromSystemPath( pItemImpl->m_pFullPath, &pStatus->ustrFileURL );
+        if (error != osl_File_E_None)
+            return error;
         pStatus->uValidFields |= osl_FileStatus_Mask_FileURL;
     }
 
commit 6059652fba10c0c03b8270c75cc53d6f60ce86c4
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jan 16 13:57:03 2013 +0100

    Move addSingletonContextEntries to ServiceManager
    
    Change-Id: I2a4c5b1f1f735e2bf5a8670d2f957f84388f0164

diff --git a/cppuhelper/source/defaultbootstrap.cxx b/cppuhelper/source/defaultbootstrap.cxx
index e0ff2d8..9f0cb52 100644
--- a/cppuhelper/source/defaultbootstrap.cxx
+++ b/cppuhelper/source/defaultbootstrap.cxx
@@ -92,22 +92,7 @@ cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri)
             css::uno::makeAny(
                 cppuhelper::detail::create_bootstrap_macro_expander_factory()),
             true));
-    cppuhelper::ServiceManager::Data const & data = smgr->getData();
-    for (cppuhelper::ServiceManager::Data::ImplementationMap::const_iterator i(
-             data.singletons.begin());
-         i != data.singletons.end(); ++i)
-    {
-        assert(!i->second.empty());
-        assert(i->second[0].get() != 0);
-        SAL_INFO_IF(
-            i->second.size() > 1, "cppuhelper",
-            "Arbitrarily chosing " << i->second[0]->info->name
-                << " among multiple implementations for " << i->first);
-        context_values.push_back(
-            cppu::ContextEntry_Init(
-                "/singletons/" + i->first,
-                css::uno::makeAny(i->second[0]->info->name), true));
-    }
+    smgr->addSingletonContextEntries(&context_values);
     context_values.push_back(
         cppu::ContextEntry_Init(
             "/services/com.sun.star.security.AccessController/mode",
diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx
index bdf1b1a..dcb7af9 100644
--- a/cppuhelper/source/servicemanager.cxx
+++ b/cppuhelper/source/servicemanager.cxx
@@ -29,6 +29,7 @@
 #include "com/sun/star/uno/Reference.hxx"
 #include "com/sun/star/uno/XComponentContext.hpp"
 #include "cppuhelper/bootstrap.hxx"
+#include "cppuhelper/component_context.hxx"
 #include "cppuhelper/implbase1.hxx"
 #include "cppuhelper/implbase3.hxx"
 #include "cppuhelper/shlib.hxx"
@@ -38,6 +39,7 @@
 #include "rtl/ref.hxx"
 #include "rtl/uri.hxx"
 #include "rtl/ustring.hxx"
+#include "sal/log.hxx"
 #include "xmlreader/xmlreader.hxx"
 
 #include "paths.hxx"
@@ -596,6 +598,26 @@ void FactoryWrapper::loadImplementation(
 
 }
 
+void cppuhelper::ServiceManager::addSingletonContextEntries(
+    std::vector< cppu::ContextEntry_Init > * entries) const
+{
+    assert(entries != 0);
+    for (Data::ImplementationMap::const_iterator i(data_.singletons.begin());
+         i != data_.singletons.end(); ++i)
+    {
+        assert(!i->second.empty());
+        assert(i->second[0].get() != 0);
+        SAL_INFO_IF(
+            i->second.size() > 1, "cppuhelper",
+            "Arbitrarily chosing " << i->second[0]->info->name
+                << " among multiple implementations for " << i->first);
+        entries->push_back(
+            cppu::ContextEntry_Init(
+                "/singletons/" + i->first,
+                css::uno::makeAny(i->second[0]->info->name), true));
+    }
+}
+
 void cppuhelper::ServiceManager::loadImplementation(
         css::uno::Reference< css::uno::XComponentContext > const & context,
         boost::shared_ptr< Data::ImplementationInfo > const & info,
diff --git a/cppuhelper/source/servicemanager.hxx b/cppuhelper/source/servicemanager.hxx
index 013bef0..b57891e 100644
--- a/cppuhelper/source/servicemanager.hxx
+++ b/cppuhelper/source/servicemanager.hxx
@@ -34,6 +34,8 @@
 #include "registry/registry.hxx"
 #include "rtl/ustring.hxx"
 
+namespace cppu { struct ContextEntry_Init; }
+
 namespace cppuhelper {
 
 typedef cppu::WeakComponentImplHelper8<
@@ -142,13 +144,14 @@ public:
         context_ = context;
     }
 
+    void addSingletonContextEntries(
+        std::vector< cppu::ContextEntry_Init > * entries) const;
+
     css::uno::Reference< css::uno::XComponentContext > getContext() const {
         assert(context_.is());
         return context_;
     }
 
-    Data const & getData() const { return data_; }
-
     void loadImplementation(
         css::uno::Reference< css::uno::XComponentContext > const & context,
         boost::shared_ptr< Data::ImplementationInfo > const & info,
commit 882aaee5ff76dbcba74ecea615393628519e14e1
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jan 16 13:35:29 2013 +0100

    UNO methods are no longer called directly on ServiceManager
    
    Change-Id: I037ed9899873e614e9e10c89f1f8a74efa73d737

diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx
index a389fd7..bdf1b1a 100644
--- a/cppuhelper/source/servicemanager.cxx
+++ b/cppuhelper/source/servicemanager.cxx
@@ -656,6 +656,34 @@ void cppuhelper::ServiceManager::loadImplementation(
     }
 }
 
+void cppuhelper::ServiceManager::disposing() {
+    std::vector< css::uno::Reference< css::lang::XComponent > > comps;
+    Data clear;
+    {
+        osl::MutexGuard g(rBHelper.rMutex);
+        for (Data::DynamicImplementations::const_iterator i(
+                 data_.dynamicImplementations.begin());
+             i != data_.dynamicImplementations.end(); ++i)
+        {
+            assert(i->second.get() != 0);
+            if (i->second->component.is()) {
+                comps.push_back(i->second->component);
+            }
+        }
+        data_.namedImplementations.swap(clear.namedImplementations);
+        data_.dynamicImplementations.swap(clear.dynamicImplementations);
+        data_.services.swap(clear.services);
+        data_.singletons.swap(clear.singletons);
+    }
+    for (std::vector<
+             css::uno::Reference< css::lang::XComponent > >::const_iterator i(
+                 comps.begin());
+         i != comps.end(); ++i)
+    {
+        removeEventListenerFromComponent(*i);
+    }
+}
+
 rtl::OUString cppuhelper::ServiceManager::getImplementationName()
     throw (css::uno::RuntimeException)
 {
@@ -1102,34 +1130,6 @@ void cppuhelper::ServiceManager::disposing(
         false);
 }
 
-void cppuhelper::ServiceManager::disposing() {
-    std::vector< css::uno::Reference< css::lang::XComponent > > comps;
-    Data clear;
-    {
-        osl::MutexGuard g(rBHelper.rMutex);
-        for (Data::DynamicImplementations::const_iterator i(
-                 data_.dynamicImplementations.begin());
-             i != data_.dynamicImplementations.end(); ++i)
-        {
-            assert(i->second.get() != 0);
-            if (i->second->component.is()) {
-                comps.push_back(i->second->component);
-            }
-        }
-        data_.namedImplementations.swap(clear.namedImplementations);
-        data_.dynamicImplementations.swap(clear.dynamicImplementations);
-        data_.services.swap(clear.services);
-        data_.singletons.swap(clear.singletons);
-    }
-    for (std::vector<
-             css::uno::Reference< css::lang::XComponent > >::const_iterator i(
-                 comps.begin());
-         i != comps.end(); ++i)
-    {
-        removeEventListenerFromComponent(*i);
-    }
-}
-
 void cppuhelper::ServiceManager::removeEventListenerFromComponent(
     css::uno::Reference< css::lang::XComponent > const & component)
 {
diff --git a/cppuhelper/source/servicemanager.hxx b/cppuhelper/source/servicemanager.hxx
index e4a9dfa..013bef0 100644
--- a/cppuhelper/source/servicemanager.hxx
+++ b/cppuhelper/source/servicemanager.hxx
@@ -155,6 +155,11 @@ public:
         css::uno::Reference< css::lang::XSingleComponentFactory > * factory1,
         css::uno::Reference< css::lang::XSingleServiceFactory > * factory2);
 
+private:
+    virtual ~ServiceManager() {}
+
+    virtual void SAL_CALL disposing();
+
     virtual rtl::OUString SAL_CALL getImplementationName()
         throw (css::uno::RuntimeException);
 
@@ -278,11 +283,6 @@ public:
     virtual void SAL_CALL disposing(css::lang::EventObject const & Source)
         throw (css::uno::RuntimeException);
 
-private:
-    virtual ~ServiceManager() {}
-
-    virtual void SAL_CALL disposing();
-
     // needs to be called with rBHelper.rMutex locked:
     bool isDisposed() { return rBHelper.bDisposed || rBHelper.bInDispose; }
 


More information about the Libreoffice-commits mailing list