summaryrefslogtreecommitdiff
path: root/basic/source/sbx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-06-19 23:10:57 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-06-20 12:46:27 +0200
commitf4ff0ed55707078868415541c4a1aebd3db1e142 (patch)
tree1739eb7d535dd1f3f30fb7313797556b0cbcb1c5 /basic/source/sbx
parent2c68c419c1fce6de1a81e1f13a84b7069125a204 (diff)
tdf#149622: also clear return value before calling method from SbxObject::Call
Moves the custom cleanup logic to overridden SbxMethod::Clear, to simplify the cleanup code and make sure it restores empty Variant correctly. Change-Id: I01fa0529acd9ac787ffcda60fd6836ade4afdcb1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136108 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'basic/source/sbx')
-rw-r--r--basic/source/sbx/sbxobj.cxx34
1 files changed, 34 insertions, 0 deletions
diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx
index 7f3560a62003..a6cbeaba5ca7 100644
--- a/basic/source/sbx/sbxobj.cxx
+++ b/basic/source/sbx/sbxobj.cxx
@@ -29,6 +29,7 @@
#include <basic/sbxmeth.hxx>
#include <sbxprop.hxx>
#include <svl/SfxBroadcaster.hxx>
+#include "sbxdec.hxx"
#include "sbxres.hxx"
@@ -262,6 +263,9 @@ bool SbxObject::Call( const OUString& rName, SbxArray* pParam )
SbxVariable* pMeth = FindQualified( rName, SbxClassType::DontCare);
if( dynamic_cast<const SbxMethod*>( pMeth) )
{
+ // tdf#149622 - clear return value of the method before calling it
+ pMeth->Clear();
+
// FindQualified() might have struck already!
if( pParam )
{
@@ -850,6 +854,36 @@ SbxClassType SbxMethod::GetClass() const
return SbxClassType::Method;
}
+void SbxMethod::Clear()
+{
+ // Release referenced data, and reset data type to the function return type
+ // Implementation similar to SbxValue::SetType
+ // tdf#143582: Don't take "read-only" flag into account, allow clearing method return value
+ switch (aData.eType)
+ {
+ case SbxSTRING:
+ delete aData.pOUString;
+ break;
+ case SbxOBJECT:
+ if (aData.pObj)
+ {
+ if (aData.pObj != this)
+ {
+ bool bParentProp = (GetUserData() & 0xFFFF) == 5345; // See sbxvalue.cxx
+ if (!bParentProp)
+ aData.pObj->ReleaseRef();
+ }
+ }
+ break;
+ case SbxDECIMAL:
+ releaseDecimalPtr(aData.pDecimal);
+ break;
+ default:
+ break;
+ }
+ aData.clear(IsFixed() ? aData.eType : SbxEMPTY);
+}
+
SbxProperty::SbxProperty( const OUString& r, SbxDataType t )
: SbxVariable( t )
{