summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-05-30 12:24:42 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-05-30 16:00:35 +0200
commita6856795267509aaf0b4f59a9fb3a626411d1cb6 (patch)
tree1aec9b53493454e37b371ec9a5fa6b82be6016f5
parent5b676a480a68f2ad7ceb107147a2ab3363b4d22d (diff)
cid#1504574 Resource leak
make an owner for the PropertyMapEntries Change-Id: Ie915a8a312f2b24488566814ad67fdeef89b5941 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135123 Tested-by: Jenkins Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--basic/source/classes/propacc.cxx15
-rw-r--r--basic/source/inc/propacc.hxx3
-rw-r--r--comphelper/source/property/propertysetinfo.cxx20
-rw-r--r--framework/source/fwi/uielement/constitemcontainer.cxx14
-rw-r--r--include/comphelper/propertysetinfo.hxx1
5 files changed, 20 insertions, 33 deletions
diff --git a/basic/source/classes/propacc.cxx b/basic/source/classes/propacc.cxx
index 06bba39073d7..4c948c3038af 100644
--- a/basic/source/classes/propacc.cxx
+++ b/basic/source/classes/propacc.cxx
@@ -54,17 +54,10 @@ Reference< XPropertySetInfo > SbPropertyValues::getPropertySetInfo()
// create on demand?
if (!m_xInfo.is())
{
- uno::Sequence<beans::Property> props(m_aPropVals.size());
- for (size_t n = 0; n < m_aPropVals.size(); ++n)
- {
- Property &rProp = props.getArray()[n];
- const PropertyValue &rPropVal = m_aPropVals[n];
- rProp.Name = rPropVal.Name;
- rProp.Handle = rPropVal.Handle;
- rProp.Type = cppu::UnoType<void>::get();
- rProp.Attributes = 0;
- }
- m_xInfo.set(new ::comphelper::PropertySetInfo(props));
+ assert(m_aPropInfos.empty());
+ for (auto const& it : m_aPropVals)
+ m_aPropInfos.emplace_back(it.Name, it.Handle, cppu::UnoType<void>::get(), 0, 0);
+ m_xInfo.set(new ::comphelper::PropertySetInfo(m_aPropInfos));
}
return m_xInfo;
}
diff --git a/basic/source/inc/propacc.hxx b/basic/source/inc/propacc.hxx
index 66dd26cefe63..bb2d13d50216 100644
--- a/basic/source/inc/propacc.hxx
+++ b/basic/source/inc/propacc.hxx
@@ -22,11 +22,13 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/beans/XPropertyAccess.hpp>
+#include <comphelper/propertysetinfo.hxx>
#include <cppuhelper/implbase.hxx>
#include <vector>
typedef std::vector<css::beans::PropertyValue> SbPropertyValueArr_Impl;
+typedef std::vector<comphelper::PropertyMapEntry> SbPropertyInfoArr_Impl;
typedef ::cppu::WeakImplHelper< css::beans::XPropertySet,
css::beans::XPropertyAccess > SbPropertyValuesHelper;
@@ -35,6 +37,7 @@ typedef ::cppu::WeakImplHelper< css::beans::XPropertySet,
class SbPropertyValues final : public SbPropertyValuesHelper
{
SbPropertyValueArr_Impl m_aPropVals;
+ SbPropertyInfoArr_Impl m_aPropInfos;
css::uno::Reference< css::beans::XPropertySetInfo > m_xInfo;
private:
diff --git a/comphelper/source/property/propertysetinfo.cxx b/comphelper/source/property/propertysetinfo.cxx
index 6385965c0d56..206129c5f595 100644
--- a/comphelper/source/property/propertysetinfo.cxx
+++ b/comphelper/source/property/propertysetinfo.cxx
@@ -47,26 +47,6 @@ PropertySetInfo::PropertySetInfo( o3tl::span<const PropertyMapEntry> pMap ) noex
}
}
-PropertySetInfo::PropertySetInfo(uno::Sequence<beans::Property> const& rProps) noexcept
-{
- PropertyMapEntry * pEntries(new PropertyMapEntry[rProps.getLength()]);
- PropertyMapEntry * pEntry(&pEntries[0]);
- for (auto const& it : rProps)
- {
- // check for duplicates
- assert(maPropertyMap.find(it.Name) == maPropertyMap.end());
-
- pEntry->maName = it.Name;
- pEntry->mnHandle = it.Handle;
- pEntry->maType = it.Type;
- pEntry->mnAttributes = it.Attributes;
- pEntry->mnMemberId = 0;
-
- maPropertyMap.emplace(it.Name, pEntry);
- ++pEntry;
- }
-}
-
PropertySetInfo::~PropertySetInfo() noexcept
{
}
diff --git a/framework/source/fwi/uielement/constitemcontainer.cxx b/framework/source/fwi/uielement/constitemcontainer.cxx
index f9840d52ec3b..7e43a5009c36 100644
--- a/framework/source/fwi/uielement/constitemcontainer.cxx
+++ b/framework/source/fwi/uielement/constitemcontainer.cxx
@@ -190,12 +190,24 @@ Any SAL_CALL ConstItemContainer::getByIndex( sal_Int32 Index )
return Any( m_aItemVector[Index] );
}
+namespace
+{
+ std::vector<comphelper::PropertyMapEntry> makePropertyMap(const css::uno::Sequence<css::beans::Property>& rProps)
+ {
+ std::vector<comphelper::PropertyMapEntry> aEntries;
+ for (auto const& it : rProps)
+ aEntries.emplace_back(it.Name, it.Handle, it.Type, it.Attributes, 0);
+ return aEntries;
+ }
+}
+
// XPropertySet
Reference< XPropertySetInfo > SAL_CALL ConstItemContainer::getPropertySetInfo()
{
// Create structure of propertysetinfo for baseclass "OPropertySetHelper".
// (Use method "getInfoHelper()".)
- static Reference< XPropertySetInfo > xInfo(new comphelper::PropertySetInfo(getInfoHelper().getProperties()));
+ static std::vector<comphelper::PropertyMapEntry> aPropertyInfos(makePropertyMap(getInfoHelper().getProperties()));
+ static Reference< XPropertySetInfo > xInfo(new comphelper::PropertySetInfo(aPropertyInfos));
return xInfo;
}
diff --git a/include/comphelper/propertysetinfo.hxx b/include/comphelper/propertysetinfo.hxx
index 4f7ac39c29f3..ee26d86982e4 100644
--- a/include/comphelper/propertysetinfo.hxx
+++ b/include/comphelper/propertysetinfo.hxx
@@ -91,7 +91,6 @@ class COMPHELPER_DLLPUBLIC PropertySetInfo final
public:
PropertySetInfo() noexcept;
PropertySetInfo( o3tl::span<const PropertyMapEntry> pMap ) noexcept;
- PropertySetInfo(css::uno::Sequence<css::beans::Property> const &) noexcept;
virtual ~PropertySetInfo() noexcept override;
/** returns a stl map with all PropertyMapEntry pointer.<p>