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>
This commit is contained in:
@@ -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
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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() );
|
||||
|
@@ -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();
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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();
|
||||
|
||||
{
|
||||
|
@@ -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
|
||||
|
@@ -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 ] );
|
||||
}
|
||||
|
Reference in New Issue
Block a user