[Libreoffice-commits] core.git: 12 commits - basic/source connectivity/source cppu/source extensions/source javaunohelper/source package/source sc/source svtools/source svx/source unotest/source vcl/generic

Caolán McNamara caolanm at redhat.com
Thu Oct 30 03:33:45 PDT 2014


 basic/source/classes/sbunoobj.cxx                       |    2 
 basic/source/runtime/methods.cxx                        |    1 
 basic/source/runtime/methods1.cxx                       |    4 +
 basic/source/runtime/runtime.cxx                        |    1 
 connectivity/source/drivers/mork/MorkParser.cxx         |    5 +
 cppu/source/typelib/static_types.cxx                    |    3 -
 cppu/source/typelib/typelib.cxx                         |    1 
 extensions/source/scanner/grid.cxx                      |    8 ++-
 javaunohelper/source/javaunohelper.cxx                  |   24 +++++----
 package/source/xstor/owriteablestream.cxx               |   23 +++++++-
 package/source/xstor/xstorage.cxx                       |    2 
 package/source/zippackage/ZipPackage.cxx                |   41 +++++++++++++---
 sc/source/filter/excel/xichart.cxx                      |   12 +++-
 svtools/source/svhtml/htmlout.cxx                       |    1 
 svx/source/customshapes/EnhancedCustomShapeFontWork.cxx |   36 ++++++++------
 unotest/source/cpp/officeconnection.cxx                 |    1 
 vcl/generic/print/genpspgraphics.cxx                    |    1 
 vcl/generic/print/text_gfx.cxx                          |    2 
 18 files changed, 122 insertions(+), 46 deletions(-)

New commits:
commit 3707022b9b72f317c50a353c64ff21bdd0ffdb69
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 30 10:17:28 2014 +0000

    coverity#735298 Unchecked return value
    
    Change-Id: I66499283f4218662146c380f605bb20b8a2ff49a

diff --git a/connectivity/source/drivers/mork/MorkParser.cxx b/connectivity/source/drivers/mork/MorkParser.cxx
index 8057b09..2cfde00 100644
--- a/connectivity/source/drivers/mork/MorkParser.cxx
+++ b/connectivity/source/drivers/mork/MorkParser.cxx
@@ -296,7 +296,10 @@ bool MorkParser::parseCell()
             {
                 Text += NextChar;
             }
-            else nextChar();
+            else
+            {
+                (void)nextChar();
+            }
         }
         break;
         case '$':
commit cb0e009a9e6903fc7b814c38b60f3f895a878028
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 30 10:10:09 2014 +0000

    document array_vs_singleton dismissals
    
    Change-Id: I8d7eb4c01197e885abca717c7814c61a7641ac9d

diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 3106708..0ff6393 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -905,6 +905,7 @@ Type getUnoTypeForSbxValue( const SbxValue* pVal )
                     sal_Int32 nIdx = nLower;
                     for( sal_Int32 i = 0 ; i < nSize ; i++,nIdx++ )
                     {
+                        // coverity[array_vs_singleton]
                         SbxVariableRef xVar = pArray->Get32( &nIdx );
                         Type aType = getUnoTypeForSbxValue( (SbxVariable*)xVar );
                         if( bNeedsInit )
@@ -1350,6 +1351,7 @@ Any sbxToUnoValue( const SbxValue* pVar, const Type& rType, Property* pUnoProper
                     sal_Int32 nIdx = nLower;
                     for( sal_Int32 i = 0 ; i < nSeqSize ; i++,nIdx++ )
                     {
+                        // coverity[array_vs_singleton]
                         SbxVariableRef xVar = pArray->Get32( &nIdx );
 
                         // Convert the value of Sbx to Uno
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 194b06b..4ab4fff 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -4372,6 +4372,7 @@ RTLFUNC(StrConv)
             {
                 ++index;
             }
+            // coverity[array_vs_singleton]
             pArray->Put( pNew, &index );
         }
 
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 2e82486..3c81652 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -839,6 +839,7 @@ RTLFUNC(Array)
         {
             ++index;
         }
+        // coverity[array_vs_singleton]
         pArray->Put( pNew, &index );
     }
 
@@ -1731,8 +1732,9 @@ RTLFUNC(Join)
         OUString aRetStr;
         short nLower, nUpper;
         pArr->GetDim( 1, nLower, nUpper );
-        for( short i = nLower ; i <= nUpper ; ++i )
+        for (short i = nLower; i <= nUpper; ++i)
         {
+            // coverity[array_vs_singleton]
             OUString aStr = pArr->Get( &i )->GetOUString();
             aRetStr += aStr;
             if( i != nUpper )
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 8cae088..455611f 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -669,6 +669,7 @@ void SbiRuntime::SetParameters( SbxArray* pParams )
                 {
                     SbxVariable* v = pParams->Get( j );
                     short nDimIndex = j - i;
+                    // coverity[array_vs_singleton]
                     pArray->Put( v, &nDimIndex );
                 }
                 SbxVariable* pArrayVar = new SbxVariable( SbxVARIANT );
diff --git a/cppu/source/typelib/static_types.cxx b/cppu/source/typelib/static_types.cxx
index 82640a0..887a884 100644
--- a/cppu/source/typelib/static_types.cxx
+++ b/cppu/source/typelib/static_types.cxx
@@ -439,18 +439,17 @@ CPPU_DLLPUBLIC void SAL_CALL typelib_static_struct_type_init(
         ppMembers, pParameterizedTypes);
 }
 
-
 CPPU_DLLPUBLIC void SAL_CALL typelib_static_interface_type_init(
     typelib_TypeDescriptionReference ** ppRef,
     const sal_Char * pTypeName,
     typelib_TypeDescriptionReference * pBaseType )
     SAL_THROW_EXTERN_C()
 {
+    // coverity[array_vs_singleton]
     typelib_static_mi_interface_type_init(
         ppRef, pTypeName, pBaseType == 0 ? 0 : 1, &pBaseType);
 }
 
-
 CPPU_DLLPUBLIC void SAL_CALL typelib_static_mi_interface_type_init(
     typelib_TypeDescriptionReference ** ppRef,
     const sal_Char * pTypeName,
diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx
index 56f8c85..b0b1a17 100644
--- a/cppu/source/typelib/typelib.cxx
+++ b/cppu/source/typelib/typelib.cxx
@@ -901,6 +901,7 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_newInterface(
     typelib_TypeDescriptionReference ** ppMembers )
     SAL_THROW_EXTERN_C()
 {
+    // coverity[array_vs_singleton]
     typelib_typedescription_newMIInterface(
         ppRet, pTypeName, 0, 0, 0, 0, 0, pBaseInterface == 0 ? 0 : 1,
         &pBaseInterface, nMembers, ppMembers);
diff --git a/svtools/source/svhtml/htmlout.cxx b/svtools/source/svhtml/htmlout.cxx
index 4e23951..54941d3 100644
--- a/svtools/source/svhtml/htmlout.cxx
+++ b/svtools/source/svhtml/htmlout.cxx
@@ -455,6 +455,7 @@ static OString lcl_ConvertCharToHTML( sal_Unicode c,
             // If the character could not be converted to the destination
             // character set, the UNICODE character is exported as character
             // entity.
+            // coverity[array_vs_singleton]
             nLen = rtl_convertUnicodeToText(
                                 rContext.m_hConv, rContext.m_hContext, &c, 0,
                                 cBuffer, TXTCONV_BUFFER_SIZE,
diff --git a/unotest/source/cpp/officeconnection.cxx b/unotest/source/cpp/officeconnection.cxx
index ec1a8e6..b86a4c2 100644
--- a/unotest/source/cpp/officeconnection.cxx
+++ b/unotest/source/cpp/officeconnection.cxx
@@ -81,6 +81,7 @@ void OfficeConnection::setUp() {
         {
             envs = &argEnv.pData;
         }
+        // coverity[array_vs_singleton]
         CPPUNIT_ASSERT_EQUAL(
             osl_Process_E_None,
             osl_executeProcess(
diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx
index 644e4fd..f83d7bc 100644
--- a/vcl/generic/print/genpspgraphics.cxx
+++ b/vcl/generic/print/genpspgraphics.cxx
@@ -638,6 +638,7 @@ bool PspFontLayout::LayoutText( ImplLayoutArgs& rArgs )
 
         // update fallback_runs if needed
         psp::CharacterMetric aMetric;
+        // coverity[array_vs_singleton]
         mrPrinterGfx.GetFontMgr().getMetrics( mnFontID, cChar, cChar, &aMetric, mbVertical );
         if( aMetric.width == -1 && aMetric.height == -1 )
             rArgs.NeedFallback( nCharPos, bRightToLeft );
diff --git a/vcl/generic/print/text_gfx.cxx b/vcl/generic/print/text_gfx.cxx
index c97a369..4074445 100644
--- a/vcl/generic/print/text_gfx.cxx
+++ b/vcl/generic/print/text_gfx.cxx
@@ -329,6 +329,7 @@ PrinterGfx::DrawText (
     for( int n = 0; n < nLen; n++ )
     {
         CharacterMetric aBBox;
+        // coverity[array_vs_singleton]
         pFontMap[n]   = getCharMetric (aFont, pEffectiveStr[n], &aBBox);
         pCharWidth[n] = getCharWidth  (mbTextVertical, pEffectiveStr[n], &aBBox);
     }
@@ -643,6 +644,7 @@ PrinterGfx::GetCharWidth (sal_Unicode nFrom, sal_Unicode nTo, long *pWidthArray)
     for( int n = 0; n < (nTo - nFrom + 1); n++ )
     {
         CharacterMetric aBBox;
+        // coverity[array_vs_singleton]
         getCharMetric (aFont, n + nFrom, &aBBox);
         pWidthArray[n] = getCharWidth (mbTextVertical, n + nFrom, &aBBox);
     }
commit 2bc6b0d5f06a4608f9bb43bdc0775b9e59e7126b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 30 10:00:04 2014 +0000

    coverity#706568 Uncaught exception
    
    Change-Id: I05a7700b782d63654406139532a775173295ea9f

diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index facd494..4e5061b 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -2174,7 +2174,15 @@ uno::Reference< io::XOutputStream > SAL_CALL OWriteStream::getOutputStream()
 {
     ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
 
-    CheckInitOnDemand();
+    try
+    {
+        CheckInitOnDemand();
+    }
+    catch( const io::IOException& r )
+    {
+        throw lang::WrappedTargetRuntimeException("OWriteStream::getOutputStream: Could not create backing temp file",
+                static_cast < OWeakObject * > ( this ), makeAny ( r ) );
+    }
 
     if ( !m_pImpl )
     {
commit 6bff65dfa66cfeb115c7db6cf2e4d6e5df323703
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 30 09:55:44 2014 +0000

    coverity#706569 Uncaught exception
    
    Change-Id: I7c1245eacd92b5869e6dab0389ee0ca3cebd98da

diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index e7a1d05..facd494 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -3161,9 +3161,16 @@ uno::Any SAL_CALL OWriteStream::getPropertyValue( const OUString& aProp )
         return uno::makeAny( m_pImpl->m_bUseCommonEncryption );
     else if ( aPropertyName == "Size" )
     {
-        CheckInitOnDemand();
-
-        if ( !m_xSeekable.is() )
+        bool bThrow = false;
+        try
+        {
+            CheckInitOnDemand();
+        }
+        catch (const io::IOException&)
+        {
+            bThrow = true;
+        }
+        if (bThrow || !m_xSeekable.is())
             throw uno::RuntimeException();
 
         return uno::makeAny( m_xSeekable->getLength() );
commit dd59e89b8fc4d9f59df3ff64b992178f2a2674da
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 30 09:53:58 2014 +0000

    OSL_ENSURE->assert when follow by deref of tested pointer
    
    Change-Id: Ib703cb24619228c081c156c4ed52bf7b878fbedd

diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx
index cb1e4f4..0b1193f 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -5990,7 +5990,7 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openStreamEle
         // the transacted version of the stream should be opened
 
         SotElement_Impl *pElement = OpenStreamElement_Impl( aStreamPath, nOpenMode, false );
-        OSL_ENSURE( pElement && pElement->m_pStream, "In case element can not be created an exception must be thrown!" );
+        assert(pElement && pElement->m_pStream && "In case element can not be created an exception must be thrown!");
 
         xResult = uno::Reference< embed::XExtendedStorageStream >(
                         pElement->m_pStream->GetStream( nOpenMode, true ),
commit 6175ccdad147cd6ef7143c03e30c0f2835d9a15d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 30 09:52:28 2014 +0000

    coverity#706582 Uncaught exception
    
    Change-Id: I82fad3f152fe5a563675686accedb583d07d2b13

diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 92e34a1..d210d45 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -1362,8 +1362,16 @@ void SAL_CALL ZipPackage::commitChanges()
     }
     // first the writeTempFile is called, if it returns a stream the stream should be written to the target
     // if no stream was returned, the file was written directly, nothing should be done
-
-    uno::Reference< io::XInputStream > xTempInStream = writeTempFile();
+    uno::Reference< io::XInputStream > xTempInStream;
+    try
+    {
+        xTempInStream = writeTempFile();
+    }
+    catch (const ucb::ContentCreationException& r)
+    {
+        throw WrappedTargetException(THROW_WHERE "Temporary file should be createable!",
+                    static_cast < OWeakObject * > ( this ), makeAny ( r ) );
+    }
     if ( xTempInStream.is() )
     {
         uno::Reference< io::XSeekable > xTempSeek( xTempInStream, uno::UNO_QUERY_THROW );
commit 125727c94f4970b697ef4d94b8a6e0a67135e73e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 30 09:50:28 2014 +0000

    coverity#706583 Uncaught exception
    
    Change-Id: I508eb91d7c32e8604525511c33c39471afd3ffbf

diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 7543bc6..92e34a1 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -1378,8 +1378,16 @@ void SAL_CALL ZipPackage::commitChanges()
                     static_cast < OWeakObject * > ( this ), makeAny ( r ) );
         }
 
-        // connect to the temporary stream
-        ConnectTo( xTempInStream );
+        try
+        {
+            // connect to the temporary stream
+            ConnectTo( xTempInStream );
+        }
+        catch( const io::IOException& r )
+        {
+            throw WrappedTargetException(THROW_WHERE "Temporary file should be connectable!",
+                    static_cast < OWeakObject * > ( this ), makeAny ( r ) );
+        }
 
         if ( m_eMode == e_IMode_XStream )
         {
commit fe0e3580e84847c46d653cee01e8e52334475192
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 30 09:48:13 2014 +0000

    coverity#706584 Uncaught exception
    
    Change-Id: I9521ed7d75cae1a1e90fd73dd7b8bd822ab4521f

diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 63fee5d..7543bc6 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -38,6 +38,7 @@
 #include <com/sun/star/io/XTruncate.hpp>
 #include <com/sun/star/io/XSeekable.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/ucb/IOErrorCode.hpp>
 #include <ucbhelper/content.hxx>
@@ -869,7 +870,8 @@ sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName )
 
     if ( ( nIndex = aName.getLength() ) == 1 && *aName.getStr() == '/' )
         return sal_True;
-    else
+
+    try
     {
         nStreamIndex = aName.lastIndexOf ( '/' );
         bool bFolder = nStreamIndex == nIndex-1;
@@ -935,8 +937,19 @@ sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName )
                 return sal_True;
             }
         }
-        return sal_False;
     }
+    catch (const uno::RuntimeException &)
+    {
+        throw;
+    }
+    catch (const uno::Exception&)
+    {
+        uno::Any e(::cppu::getCaughtException());
+        throw lang::WrappedTargetRuntimeException(
+            OUString("ZipPackage::hasByHierarchicalName"),
+            0, uno::makeAny(e));
+    }
+    return sal_False;
 }
 
 uno::Reference< XInterface > SAL_CALL ZipPackage::createInstance()
commit 32be2ae62aaf7b8eb5621f68be507088410781de
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 30 09:35:59 2014 +0000

    coverity#705665 osl_Module->osl::Module
    
    and
    
    coverity#705666 Resource leak
    
    still actually fails to dlclose module, but explicitly does that
    
    Change-Id: Idbf5608b052e3a7c5a465a73d8ad067a0a9494c5

diff --git a/javaunohelper/source/javaunohelper.cxx b/javaunohelper/source/javaunohelper.cxx
index 54d2864..05ad4c0 100644
--- a/javaunohelper/source/javaunohelper.cxx
+++ b/javaunohelper/source/javaunohelper.cxx
@@ -20,7 +20,7 @@
 #include "sal/config.h"
 
 #include <osl/diagnose.h>
-#include <osl/module.h>
+#include <osl/module.hxx>
 
 #include <uno/environment.hxx>
 #include <uno/lbnames.h>
@@ -65,13 +65,14 @@ jboolean Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1writeInfo(
 
     fprintf(stderr, "Hmm, %s called for %s\n", __PRETTY_FUNCTION__, OUStringToOString(pJLibName, RTL_TEXTENCODING_JAVA_UTF8).getStr());
 #else
-    oslModule lib = osl_loadModule( aLibName.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
-    if (lib)
+    osl::Module lib(aLibName, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL);
+    if (lib.is())
     {
+        lib.release();
+
         // ========================= LATEST VERSION =========================
         OUString aGetEnvName( COMPONENT_GETENV );
-        oslGenericFunction pSym =
-            osl_getFunctionSymbol( lib, aGetEnvName.pData );
+        oslGenericFunction pSym = lib.getFunctionSymbol(aGetEnvName);
         if (pSym)
         {
             Environment java_env, loader_env;
@@ -93,7 +94,7 @@ jboolean Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1writeInfo(
                 (uno_Environment **)&java_env, java_env_name.pData, vm_access.get() );
 
             OUString aWriteInfoName( COMPONENT_WRITEINFO );
-            pSym = osl_getFunctionSymbol( lib, aWriteInfoName.pData );
+            pSym = lib.getFunctionSymbol(aWriteInfoName);
             if (pSym)
             {
                 if (loader_env.is() && java_env.is())
@@ -157,13 +158,14 @@ jobject Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory(
     jobject joSLL_cpp = 0;
 
 #ifndef DISABLE_DYNLOADING
-    oslModule lib = osl_loadModule( aLibName.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
-    if (lib)
+    osl::Module lib(aLibName, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL);
+    if (lib.is())
     {
+        lib.release();
+
         // ========================= LATEST VERSION =========================
         OUString aGetEnvName( COMPONENT_GETENV );
-        oslGenericFunction pSym =
-            osl_getFunctionSymbol( lib, aGetEnvName.pData );
+        oslGenericFunction pSym = lib.getFunctionSymbol(aGetEnvName);
         if (pSym)
         {
             Environment java_env, loader_env;
@@ -186,7 +188,7 @@ jobject Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory(
                 (uno_Environment **)&java_env, java_env_name.pData, vm_access.get() );
 
             OUString aGetFactoryName( COMPONENT_GETFACTORY );
-            pSym = osl_getFunctionSymbol( lib, aGetFactoryName.pData );
+            pSym = lib.getFunctionSymbol(aGetFactoryName);
             if (pSym)
             {
                 if (loader_env.is() && java_env.is())
commit f69067fd66d898cca072ce91c2a04adc794378f0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 30 09:28:24 2014 +0000

    coverity#1244939 Division or modulo by float zero
    
    and
    
    coverity#1244938 Division or modulo by float zero
    
    Change-Id: I128b1ac10f514285152cf189af24885460c9c5ca

diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
index b3bc742..ae31f00 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
@@ -41,6 +41,7 @@
 #include <editeng/outlobj.hxx>
 #include <editeng/editobj.hxx>
 #include <editeng/editeng.hxx>
+#include <o3tl/numeric.hxx>
 #include <svx/svdmodel.hxx>
 #include <vector>
 #include <numeric>
@@ -741,22 +742,27 @@ void FitTextOutlinesToShapeOutlines( const tools::PolyPolygon& aOutlines2d, FWDa
                                 InsertMissingOutlinePoints( rOutlinePoly, vDistances, rTextAreaBoundRect, aLocalPoly );
                                 InsertMissingOutlinePoints( rOutlinePoly2, vDistances2, rTextAreaBoundRect, aLocalPoly );
 
-                                sal_uInt16 j, _nPointCount = aLocalPoly.GetSize();
-                                for ( j = 0; j < _nPointCount; j++ )
+                                sal_uInt16 _nPointCount = aLocalPoly.GetSize();
+                                if (_nPointCount)
                                 {
-                                    Point& rPoint = aLocalPoly[ j ];
-                                    rPoint.X() -= nLeft;
-                                    rPoint.Y() -= nTop;
-                                    double fX = (double)rPoint.X() / (double)nWidth;
-                                    double fY = (double)rPoint.Y() / (double)nHeight;
-
-                                    double fx1, fy1, fx2, fy2;
-                                    GetPoint( rOutlinePoly, vDistances, fX, fx1, fy1 );
-                                    GetPoint( rOutlinePoly2, vDistances2, fX, fx2, fy2 );
-                                    double fWidth = fx2 - fx1;
-                                    double fHeight= fy2 - fy1;
-                                    rPoint.X() = (sal_Int32)( fx1 + fWidth * fY );
-                                    rPoint.Y() = (sal_Int32)( fy1 + fHeight* fY );
+                                    if (!nWidth || !nHeight)
+                                        throw o3tl::divide_by_zero();
+                                    for (sal_uInt16 j = 0; j < _nPointCount; ++j)
+                                    {
+                                        Point& rPoint = aLocalPoly[ j ];
+                                        rPoint.X() -= nLeft;
+                                        rPoint.Y() -= nTop;
+                                        double fX = (double)rPoint.X() / (double)nWidth;
+                                        double fY = (double)rPoint.Y() / (double)nHeight;
+
+                                        double fx1, fy1, fx2, fy2;
+                                        GetPoint( rOutlinePoly, vDistances, fX, fx1, fy1 );
+                                        GetPoint( rOutlinePoly2, vDistances2, fX, fx2, fy2 );
+                                        double fWidth = fx2 - fx1;
+                                        double fHeight= fy2 - fy1;
+                                        rPoint.X() = (sal_Int32)( fx1 + fWidth * fY );
+                                        rPoint.Y() = (sal_Int32)( fy1 + fHeight* fY );
+                                    }
                                 }
 
                                 // write back polygon
commit f089b4fbc800452111e1b5be534e3fc00975cc54
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 30 09:24:07 2014 +0000

    coverity#735614 Division or modulo by float zero
    
    or
    
    coverity#735615 Division or modulo by float zero
    
    Change-Id: I6509e987eaf58349e81b9ebadcd7e2d0ff0bcbcb

diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index b40f61a..6313fa5 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -74,7 +74,7 @@
 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
 #include <com/sun/star/chart2/data/XDataSink.hpp>
 #include <com/sun/star/chart2/data/LabeledDataSequence.hpp>
-
+#include <o3tl/numeric.hxx>
 #include <o3tl/ptr_container.hxx>
 #include <sfx2/objsh.hxx>
 #include <svx/svdpage.hxx>
@@ -325,12 +325,18 @@ sal_Int32 XclImpChRoot::CalcHmmFromChartY( sal_Int32 nPosY ) const
 
 double XclImpChRoot::CalcRelativeFromHmmX( sal_Int32 nPosX ) const
 {
-    return static_cast< double >( nPosX ) / mxChData->maChartRect.GetWidth();
+    const long nWidth = mxChData->maChartRect.GetWidth();
+    if (!nWidth)
+        throw o3tl::divide_by_zero();
+    return static_cast<double>(nPosX) / nWidth;
 }
 
 double XclImpChRoot::CalcRelativeFromHmmY( sal_Int32 nPosY ) const
 {
-    return static_cast< double >( nPosY ) / mxChData->maChartRect.GetHeight();
+    const long nHeight = mxChData->maChartRect.GetHeight();
+    if (!nHeight)
+        throw o3tl::divide_by_zero();
+    return static_cast<double >(nPosY) / nHeight;
 }
 
 double XclImpChRoot::CalcRelativeFromChartX( sal_Int32 nPosX ) const
commit cdbfbd0f7c3ed3bd3235f97197d279c41913245b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 30 09:21:40 2014 +0000

    coverity#735608 Division or modulo by float zero
    
    and
    
    coverity#735607 Division or modulo by float zero
    
    Change-Id: Iceeab702e183d291d7b1b6ded9113d1a15163c94

diff --git a/extensions/source/scanner/grid.cxx b/extensions/source/scanner/grid.cxx
index 4956c3f..44143f5 100644
--- a/extensions/source/scanner/grid.cxx
+++ b/extensions/source/scanner/grid.cxx
@@ -306,8 +306,12 @@ Point GridWindow::transform( double x, double y )
 
 void GridWindow::transform( const Point& rOriginal, double& x, double& y )
 {
-    x = ( rOriginal.X() - m_aGridArea.Left() ) * (m_fMaxX - m_fMinX) / (double)m_aGridArea.GetWidth() + m_fMinX;
-    y = ( m_aGridArea.Bottom() - rOriginal.Y() ) * (m_fMaxY - m_fMinY) / (double)m_aGridArea.GetHeight() + m_fMinY;
+    const long nWidth = m_aGridArea.GetWidth();
+    const long nHeight = m_aGridArea.GetHeight();
+    if (!nWidth || nHeight)
+        return;
+    x = ( rOriginal.X() - m_aGridArea.Left() ) * (m_fMaxX - m_fMinX) / (double)nWidth + m_fMinX;
+    y = ( m_aGridArea.Bottom() - rOriginal.Y() ) * (m_fMaxY - m_fMinY) / (double)nHeight + m_fMinY;
 }
 
 void GridWindow::drawLine( double x1, double y1, double x2, double y2 )


More information about the Libreoffice-commits mailing list