tdf#152380: add checks for names and values sequences length equality

Change-Id: Ibeef551126874bcfffb4e7736588e2e1873f5768
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143681
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/comphelper/source/property/propagg.cxx b/comphelper/source/property/propagg.cxx
index 0d8ea6a..5a05744 100644
--- a/comphelper/source/property/propagg.cxx
+++ b/comphelper/source/property/propagg.cxx
@@ -589,6 +589,9 @@ void SAL_CALL OPropertySetAggregationHelper::setPropertyValues(
        OPropertySetHelper::setPropertyValues(_rPropertyNames, _rValues);
    else if (_rPropertyNames.getLength() == 1) // use the more efficient way
    {
        if (_rValues.getLength() != 1)
            throw IllegalArgumentException("lengths do not match", static_cast<XPropertySet*>(this),
                                           -1);
        try
        {
            setPropertyValue( _rPropertyNames[0], _rValues[0] );
@@ -631,6 +634,9 @@ void SAL_CALL OPropertySetAggregationHelper::setPropertyValues(
        // mixed
        else
        {
            if (_rValues.getLength() != nLen)
                throw IllegalArgumentException("lengths do not match",
                                               static_cast<XPropertySet*>(this), -1);
            const  css::uno::Any* pValues = _rValues.getConstArray();

            // dividing the Names and _rValues
diff --git a/cppuhelper/source/propshlp.cxx b/cppuhelper/source/propshlp.cxx
index 3af4cda..18ee9d1 100644
--- a/cppuhelper/source/propshlp.cxx
+++ b/cppuhelper/source/propshlp.cxx
@@ -25,6 +25,7 @@
#include <cppuhelper/exc_hlp.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <memory>
#include <sal/log.hxx>

@@ -867,6 +868,9 @@ void OPropertySetHelper::setPropertyValues(
    const Sequence<Any>& rValues )
{
        sal_Int32   nSeqLen = rPropertyNames.getLength();
        if (nSeqLen != rValues.getLength())
            throw IllegalArgumentException("lengths do not match", static_cast<XPropertySet*>(this),
                                           -1);
        std::unique_ptr<sal_Int32[]> pHandles(new sal_Int32[ nSeqLen ]);
        // get the map table
        IPropertyArrayHelper & rPH = getInfoHelper();
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index 4f831a7..8d6b2aa 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -746,6 +746,10 @@ void SAL_CALL SvxUnoTextRangeBase::setPropertyValues( const uno::Sequence< OUStr

void SvxUnoTextRangeBase::_setPropertyValues( const uno::Sequence< OUString >& aPropertyNames, const uno::Sequence< uno::Any >& aValues, sal_Int32 nPara )
{
    if (aPropertyNames.getLength() != aValues.getLength())
        throw lang::IllegalArgumentException("lengths do not match",
                                             static_cast<css::beans::XPropertySet*>(this), -1);

    SolarMutexGuard aGuard;

    SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx
index 700bf69..79d6be3 100644
--- a/forms/source/component/ListBox.cxx
+++ b/forms/source/component/ListBox.cxx
@@ -473,6 +473,10 @@ namespace frm
        );
        if ( ( pSelectedItemsPos != _rPropertyNames.end() ) && aStringItemListExists )
        {
            if (_rPropertyNames.getLength() != _rValues.getLength())
                throw css::lang::IllegalArgumentException("lengths do not match",
                                                          static_cast<cppu::OWeakObject*>(this), -1);

            // both properties are present
            // -> remember the value for the select sequence
            pSelectSequenceValue = _rValues.getConstArray() + ( pSelectedItemsPos - _rPropertyNames.begin() );
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index a358865..5dbc1ee 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -1282,6 +1282,9 @@ void SAL_CALL Cell::setPropertyValues( const Sequence< OUString >& aPropertyName
        throw DisposedException();

    const sal_Int32 nCount = aPropertyNames.getLength();
    if (nCount != aValues.getLength())
        throw css::lang::IllegalArgumentException("lengths do not match",
                                                  static_cast<cppu::OWeakObject*>(this), -1);

    const OUString* pNames = aPropertyNames.getConstArray();
    const Any* pValues = aValues.getConstArray();
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 0a26c69..60dd13a 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -1679,8 +1679,11 @@ void SAL_CALL SvxShape::setPropertyValues( const css::uno::Sequence< OUString >&
    ::SolarMutexGuard aSolarGuard;

    const sal_Int32 nCount = aPropertyNames.getLength();
    const OUString* pNames = aPropertyNames.getConstArray();
    if (nCount != aValues.getLength())
        throw css::lang::IllegalArgumentException("lengths do not match",
                                                  static_cast<cppu::OWeakObject*>(this), -1);

    const OUString* pNames = aPropertyNames.getConstArray();
    const uno::Any* pValues = aValues.getConstArray();

    // make sure mbIsMultiPropertyCall and mpImpl->mpItemSet are
diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx
index e741cfa..308ed9f 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -421,6 +421,10 @@ void SAL_CALL SwXParagraph::setPropertyValues(
    const uno::Sequence< OUString >& rPropertyNames,
    const uno::Sequence< uno::Any >& rValues )
{
    if (rPropertyNames.getLength() != rValues.getLength())
        throw lang::IllegalArgumentException("lengths do not match",
                                             static_cast<cppu::OWeakObject*>(this), -1);

    SolarMutexGuard aGuard;

    // workaround for bad designed API
diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx
index d34dc61..d0bc336 100644
--- a/sw/source/core/unocore/unoport.cxx
+++ b/sw/source/core/unocore/unoport.cxx
@@ -424,6 +424,10 @@ void SwXTextPortion::SetPropertyValues_Impl(
    const uno::Sequence< OUString >& rPropertyNames,
    const uno::Sequence< uno::Any >& rValues )
{
    if (rPropertyNames.getLength() != rValues.getLength())
        throw lang::IllegalArgumentException("lengths do not match",
                                             static_cast<cppu::OWeakObject*>(this), -1);

    SwUnoCursor& rUnoCursor = GetCursor();

    {
diff --git a/toolkit/source/controls/unocontrolmodel.cxx b/toolkit/source/controls/unocontrolmodel.cxx
index c5e8165..983ea89 100644
--- a/toolkit/source/controls/unocontrolmodel.cxx
+++ b/toolkit/source/controls/unocontrolmodel.cxx
@@ -1290,6 +1290,9 @@ void UnoControlModel::setPropertyValues( const css::uno::Sequence< OUString >& r
    ::osl::ClearableMutexGuard aGuard( GetMutex() );

    sal_Int32 nProps = rPropertyNames.getLength();
    if (nProps != Values.getLength())
        throw css::lang::IllegalArgumentException("lengths do not match",
                                                  static_cast<cppu::OWeakObject*>(this), -1);

//  sal_Int32* pHandles = new sal_Int32[nProps];
        // don't do this - it leaks in case of an exception
diff --git a/xmloff/source/forms/gridcolumnproptranslator.cxx b/xmloff/source/forms/gridcolumnproptranslator.cxx
index aeb1de4..b10357b 100644
--- a/xmloff/source/forms/gridcolumnproptranslator.cxx
+++ b/xmloff/source/forms/gridcolumnproptranslator.cxx
@@ -254,6 +254,9 @@ namespace xmloff
        sal_Int32 nParaAlignPos = findStringElement( aTranslatedNames, getParaAlignProperty() );
        if ( nParaAlignPos != -1 )
        {
            if (aTranslatedNames.getLength() != aTranslatedValues.getLength())
                    throw css::lang::IllegalArgumentException(
                        "lengths do not match", static_cast<cppu::OWeakObject*>(this), -1);
            aTranslatedNames.getArray()[ nParaAlignPos ] = getAlignProperty();
            valueParaAdjustToAlign( aTranslatedValues.getArray()[ nParaAlignPos ] );
        }