From f66508b4f2591b4c378523b2187c42ab8d949c35 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 23 Oct 2024 13:00:47 +0200 Subject: assert on invalid param in OPropertyContainerHelper::getFastPropertyValue which flushes out a bug in OPropertySetHelper::getPropertyValueImp Change-Id: I5d3928e55eb9f019629896ad6478011520318fd9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175474 Tested-by: Jenkins Reviewed-by: Noel Grandin (cherry picked from commit caf1bc0c4c559999d44b83ff8ace43b5e7fcf3f1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175494 Reviewed-by: Xisco Fauli --- comphelper/source/property/propertycontainerhelper.cxx | 2 +- comphelper/source/property/propshlp.cxx | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'comphelper') diff --git a/comphelper/source/property/propertycontainerhelper.cxx b/comphelper/source/property/propertycontainerhelper.cxx index ee81100ae617..1ce9ad4ea8c5 100644 --- a/comphelper/source/property/propertycontainerhelper.cxx +++ b/comphelper/source/property/propertycontainerhelper.cxx @@ -399,7 +399,7 @@ void OPropertyContainerHelper::getFastPropertyValue(Any& _rValue, sal_Int32 _nHa PropertiesIterator aPos = const_cast(this)->searchHandle(_nHandle); if (aPos == m_aProperties.end()) { - OSL_FAIL( "OPropertyContainerHelper::getFastPropertyValue: unknown handle!" ); + assert( false && "OPropertyContainerHelper::getFastPropertyValue: unknown handle" ); // should not happen if the derived class has built a correct property set info helper to be used by // our base class OPropertySetHelper return; diff --git a/comphelper/source/property/propshlp.cxx b/comphelper/source/property/propshlp.cxx index b0139c747969..d15db5c7e2df 100644 --- a/comphelper/source/property/propshlp.cxx +++ b/comphelper/source/property/propshlp.cxx @@ -176,6 +176,8 @@ Any OPropertySetHelper::getPropertyValueImpl(std::unique_lock& rGuar IPropertyArrayHelper& rPH = getInfoHelper(); // map the name to the handle sal_Int32 nHandle = rPH.getHandleByName(rPropertyName); + if (nHandle == -1) + throw UnknownPropertyException(rPropertyName); // call the method of the XFastPropertySet interface Any aAny; getFastPropertyValue(rGuard, aAny, nHandle); -- cgit