[Libreoffice-commits] core.git: 6 commits - desktop/source sw/source

Caolán McNamara caolanm at redhat.com
Fri Sep 5 08:31:28 PDT 2014


 desktop/source/deployment/manager/dp_informationprovider.cxx |   17 +++++++---
 desktop/source/deployment/manager/dp_manager.cxx             |   14 +++++++-
 desktop/source/deployment/registry/dp_backend.cxx            |   14 +++++++-
 desktop/source/deployment/registry/dp_registry.cxx           |   17 ++++++++--
 sw/source/core/unocore/unotext.cxx                           |   18 +++++------
 sw/source/filter/ww8/rtfattributeoutput.cxx                  |   10 ++----
 6 files changed, 63 insertions(+), 27 deletions(-)

New commits:
commit cca4e4704f52f3fc81b49ff3be698da1245f903a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Sep 5 16:10:46 2014 +0100

    coverity#1233486 Unchecked dynamic_cast
    
    Change-Id: Icc4faeb5597267c04591e8d68ec429344d5bd126

diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index b6f3979..4771478 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1674,14 +1674,14 @@ SwXText::convertToTextFrame(
 
     const uno::Reference<text::XTextFrame> xNewFrame(
             SwXTextFrame::CreateXTextFrame(*m_pImpl->m_pDoc, 0));
-    SwXTextFrame *const pNewFrame = dynamic_cast<SwXTextFrame*>(xNewFrame.get());
-    pNewFrame->SetSelection( aStartPam );
+    SwXTextFrame& rNewFrame = dynamic_cast<SwXTextFrame&>(*xNewFrame.get());
+    rNewFrame.SetSelection( aStartPam );
     try
     {
         const beans::PropertyValue* pValues = rFrameProperties.getConstArray();
         for (sal_Int32 nProp = 0; nProp < rFrameProperties.getLength(); ++nProp)
         {
-            pNewFrame->SwXFrame::setPropertyValue(
+            rNewFrame.SwXFrame::setPropertyValue(
                     pValues[nProp].Name, pValues[nProp].Value);
         }
 
@@ -1690,8 +1690,8 @@ SwXText::convertToTextFrame(
             const uno::Reference< text::XTextRange> xInsertTextRange =
                 new SwXTextRange(aStartPam, this);
             aStartPam.DeleteMark(); // mark position node may be deleted!
-            pNewFrame->attach( xInsertTextRange );
-            pNewFrame->setName(m_pImpl->m_pDoc->GetUniqueFrameName());
+            rNewFrame.attach( xInsertTextRange );
+            rNewFrame.setName(m_pImpl->m_pDoc->GetUniqueFrameName());
         }
 
         SwTxtNode *const pTxtNode(aStartPam.GetNode().GetTxtNode());
@@ -1704,10 +1704,10 @@ SwXText::convertToTextFrame(
                 if (aMovePam.Move( fnMoveForward, fnGoCntnt ))
                 {
                     // move the anchor to the next paragraph
-                    SwFmtAnchor aNewAnchor(pNewFrame->GetFrmFmt()->GetAnchor());
+                    SwFmtAnchor aNewAnchor(rNewFrame.GetFrmFmt()->GetAnchor());
                     aNewAnchor.SetAnchor( aMovePam.Start() );
                     m_pImpl->m_pDoc->SetAttr(
-                        aNewAnchor, *pNewFrame->GetFrmFmt() );
+                        aNewAnchor, *rNewFrame.GetFrmFmt() );
 
                     // also move frames anchored to us
                     for (size_t i = 0; i < m_pImpl->m_pDoc->GetSpzFrmFmts()->size(); ++i)
@@ -1736,11 +1736,11 @@ SwXText::convertToTextFrame(
         sMessage = rRuntime.Message;
         bRuntimeException = true;
     }
-    xRet = pNewFrame;
+    xRet = &rNewFrame;
     if (bParaBeforeInserted || bParaAfterInserted)
     {
         const uno::Reference<text::XTextCursor> xFrameTextCursor =
-            pNewFrame->createTextCursor();
+            rNewFrame.createTextCursor();
         const uno::Reference<XUnoTunnel> xTunnel(xFrameTextCursor,
                 uno::UNO_QUERY);
         SwXTextCursor *const pFrameCursor =
commit 0065cb5d48033517ea276ee3a64ea754cca615a8
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Sep 5 16:05:46 2014 +0100

    coverity#1233485 Dereference after null check
    
    Change-Id: Id862a827cde1492aa6e78f20ab5bf78e405c5dd9

diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 616631b..570af9b 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -3689,12 +3689,10 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw
     //Get original size in twips
     Size aSize(sw::util::GetSwappedInSize(*pGrfNode));
     Size aRendered(aSize);
-    if (pFlyFrmFmt)
-    {
-        const SwFmtFrmSize& rS = pFlyFrmFmt->GetFrmSize();
-        aRendered.Width() = rS.GetWidth();
-        aRendered.Height() = rS.GetHeight();
-    }
+
+    const SwFmtFrmSize& rS = pFlyFrmFmt->GetFrmSize();
+    aRendered.Width() = rS.GetWidth();
+    aRendered.Height() = rS.GetHeight();
 
     sw::Frame* pFrame = 0;
     for (sw::FrameIter it = m_rExport.maFrames.begin(); it != m_rExport.maFrames.end(); ++it)
commit 32ffdd367f5ef9e9af747bda9d46e90997a95e19
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Sep 5 15:55:34 2014 +0100

    coverity#706495 Uncaught exception
    
    Change-Id: I36a48a72e9ce305c62d9a82c8d1fbfc2ad403068

diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx
index be1e782..7ccb609 100644
--- a/desktop/source/deployment/manager/dp_informationprovider.cxx
+++ b/desktop/source/deployment/manager/dp_informationprovider.cxx
@@ -149,14 +149,21 @@ PackageInformationProvider::getPackageLocation( const OUString& _sExtensionId )
     }
     if ( !aLocationURL.isEmpty() )
     {
-        ::ucbhelper::Content aContent( aLocationURL, NULL, mxContext );
-        aLocationURL = aContent.getURL();
+        try
+        {
+            ::ucbhelper::Content aContent( aLocationURL, NULL, mxContext );
+            aLocationURL = aContent.getURL();
+        }
+        catch (const css::ucb::ContentCreationException& e)
+        {
+           SAL_WARN(
+            "desktop.deployment",
+            "ignoring ContentCreationException \"" << e.Message << "\"");
+        }
     }
     return aLocationURL;
 }
 
-
-
 uno::Sequence< uno::Sequence< OUString > > SAL_CALL
 PackageInformationProvider::isUpdateAvailable( const OUString& _sExtensionId )
     throw ( uno::RuntimeException, std::exception )
@@ -221,7 +228,7 @@ PackageInformationProvider::isUpdateAvailable( const OUString& _sExtensionId )
             extensions = extMgr->getExtensionsWithSameIdentifier(
                 dp_misc::getIdentifier(info.extension), info.extension->getName(),
                 uno::Reference<css_ucb::XCommandEnvironment>());
-        } catch (lang::IllegalArgumentException& e) {
+        } catch (const lang::IllegalArgumentException& e) {
             SAL_WARN(
                 "desktop.deployment",
                 "ignoring IllegalArgumentException \"" << e.Message << "\"");
commit 962f01c3750be3b4309232789708cb7982ced591
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Sep 5 15:53:29 2014 +0100

    coverity#983652 Uncaught exception
    
    Change-Id: I72f298c5cd0476d6e0cbf3ffaf5fdf5cd143a21c

diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx
index ebd3693..ee8f84b 100644
--- a/desktop/source/deployment/manager/dp_manager.cxx
+++ b/desktop/source/deployment/manager/dp_manager.cxx
@@ -1296,8 +1296,18 @@ bool PackageManagerImpl::synchronizeAddedExtensions(
     ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() );
     //check if the folder exist at all. The shared extension folder
     //may not exist for a normal user.
-    if (!create_ucb_content(
-            NULL, m_activePackages_expanded, Reference<css::ucb::XCommandEnvironment>(), false))
+    bool bOk=true;
+    try
+    {
+        bOk = create_ucb_content(
+                NULL, m_activePackages_expanded, Reference<css::ucb::XCommandEnvironment>(), false);
+    }
+    catch (const css::ucb::ContentCreationException&)
+    {
+        bOk = false;
+    }
+
+    if (!bOk)
         return bModified;
 
     ::ucbhelper::Content tempFolder( m_activePackages_expanded, xCmdEnv, m_xComponentContext );
diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx
index d311630..d1cd8df 100644
--- a/desktop/source/deployment/registry/dp_backend.cxx
+++ b/desktop/source/deployment/registry/dp_backend.cxx
@@ -574,7 +574,7 @@ void Package::exportTo(
 
     ::ucbhelper::Content destFolder( destFolderURL, xCmdEnv, getMyBackend()->getComponentContext() );
     ::ucbhelper::Content sourceContent( getURL(), xCmdEnv, getMyBackend()->getComponentContext() );
-    bool bOk;
+    bool bOk=true;
     try
     {
         bOk = destFolder.transferContent(
diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx
index 5131afb..a5d364d 100644
--- a/desktop/source/deployment/registry/dp_registry.cxx
+++ b/desktop/source/deployment/registry/dp_registry.cxx
@@ -464,7 +464,7 @@ Reference<deployment::XPackage> PackageRegistryImpl::bindPackage(
     if (mediaType.isEmpty())
     {
         ::ucbhelper::Content ucbContent;
-        bool bOk;
+        bool bOk=true;
 
         try
         {
commit b1a5a7e2be619be2d52094eff6802f0ef5470ca4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Sep 5 15:50:24 2014 +0100

    coverity#706497 Uncaught exception
    
    Change-Id: I6c2acde8c47f6f2c0b65b228737950a1d8972f8a

diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx
index cdf0c1d..d311630 100644
--- a/desktop/source/deployment/registry/dp_backend.cxx
+++ b/desktop/source/deployment/registry/dp_backend.cxx
@@ -574,9 +574,19 @@ void Package::exportTo(
 
     ::ucbhelper::Content destFolder( destFolderURL, xCmdEnv, getMyBackend()->getComponentContext() );
     ::ucbhelper::Content sourceContent( getURL(), xCmdEnv, getMyBackend()->getComponentContext() );
-    if (! destFolder.transferContent(
+    bool bOk;
+    try
+    {
+        bOk = destFolder.transferContent(
             sourceContent, ::ucbhelper::InsertOperation_COPY,
-            newTitle, nameClashAction ))
+            newTitle, nameClashAction);
+    }
+    catch (const css::ucb::ContentCreationException&)
+    {
+        bOk = false;
+    }
+
+    if (!bOk)
         throw RuntimeException( "UCB transferContent() failed!", 0 );
 }
 
commit 3f026077dcdee5118bc42114fd9343e4a8a4b477
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Sep 5 15:47:59 2014 +0100

    coverity#706498 Uncaught exception
    
    Change-Id: I99a5ccd930d231324b5a35fedd70320e02e358af

diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx
index dc1a689..5131afb 100644
--- a/desktop/source/deployment/registry/dp_registry.cxx
+++ b/desktop/source/deployment/registry/dp_registry.cxx
@@ -464,9 +464,20 @@ Reference<deployment::XPackage> PackageRegistryImpl::bindPackage(
     if (mediaType.isEmpty())
     {
         ::ucbhelper::Content ucbContent;
-        if (create_ucb_content(
-                &ucbContent, url, xCmdEnv, false /* no throw */ )
-                && !ucbContent.isFolder())
+        bool bOk;
+
+        try
+        {
+            bOk = create_ucb_content(
+                    &ucbContent, url, xCmdEnv, false /* no throw */ )
+                    && !ucbContent.isFolder();
+        }
+        catch (const css::ucb::ContentCreationException&)
+        {
+            bOk = false;
+        }
+
+        if (bOk)
         {
             OUString title( StrTitle::getTitle( ucbContent ) );
             for (;;)


More information about the Libreoffice-commits mailing list