basic/qa/basic_coverage/test_Vbscript_RegExp.bas | 48 +++++++++++++++++++++++ basic/source/classes/sbunoobj.cxx | 3 - 2 files changed, 48 insertions(+), 3 deletions(-)
New commits: commit b038106e8d3b24d794bfec0aa4d6b42fc470c4e4 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu Jun 12 23:32:04 2025 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Thu Jun 12 21:55:17 2025 +0200 tdf#166972: do not reset parameters in SbUnoObject::Notify Resetting parameters in this function was introduced in commit 0b21b8b146fc4b982c7c9bbb866b9ff18a29332a (initial commit for vba blob ( not including container_control stuff ), 2010-10-06). Unfortunately, the reason for that is not explained. The problem that it creates is that this code gets called eventually from SbiRuntime::FindElement (which sets parameters using SetupArgs, then calls SbiRuntime::CheckArray in the end, which calls GetObject, which performs actual data access). In SbiRuntime::CheckArray, the immediate problem was, that parameters were referenced using a raw pointer; when the parageters were cleared in GetObject, the pointer got dangling. But it wasn't enough to use e.g. SbxArrayRef there, to keep the array alive; the object will be accessed later, and needs its parameters to work. On the other hand, it feels wrong to reinstate parameters after the call to GetObject in SbiRuntime::CheckArray (getting the object can run just any code path). So I chose to try and drop the resetting of parameters in SbUnoObject::Notify. Let's see, if something breaks. Change-Id: Icadfcfb8b7e5e87b2de46166963fd97532f8713c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186432 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins diff --git a/basic/qa/basic_coverage/test_Vbscript_RegExp.bas b/basic/qa/basic_coverage/test_Vbscript_RegExp.bas new file mode 100644 index 000000000000..7f06887a5bec --- /dev/null +++ b/basic/qa/basic_coverage/test_Vbscript_RegExp.bas @@ -0,0 +1,48 @@ +' This file is part of the LibreOffice project. +' +' This Source Code Form is subject to the terms of the Mozilla Public +' License, v. 2.0. If a copy of the MPL was not distributed with this +' file, You can obtain one at http://mozilla.org/MPL/2.0/. +' + +Option Explicit + +Function doUnitTest() As String + TestUtil.TestInit + verify_testVbscript_RegExp + doUnitTest = TestUtil.GetResult() +End Function + +Sub verify_testVbscript_RegExp() + On Error GoTo errorHandler + + If GetGuiType() <> 1 Then ' Only testing on Windows + TestUtil.Assert(True) ' Mark test as succeeded + Exit Sub + End If + + Dim txt, regex, matches, item1, item2 + + txt = "This is LibreOffice for you" + + regex = CreateObject("VBScript.RegExp") + regex.Pattern = "(Li.+)(Of\w+)" + + matches = regex.Execute(txt) + + ' Test that accessing twice an indexed property (here: Item) of a COM object works + If matches.Count > 0 Then + item1 = matches.Item(0).SubMatches.Item(0) + ' Without the fix, the following line errored out: + ' Type: com.sun.star.lang.WrappedTargetRuntimeException + ' Message: [automation bridge] unexpected exception in IUnknownWrapper::getValue + item2 = matches.Item(0).SubMatches.Item(1) + End If + + TestUtil.AssertEqual(item1, "Libre", "item1") + TestUtil.AssertEqual(item2, "Office", "item2") + + Exit Sub +errorHandler: + TestUtil.ReportErrorHandler("verify_testVbscript_RegExp", Err, Error$, Erl) +End Sub diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 871e02e76f1f..4dffb8fec5eb 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -2100,9 +2100,6 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) aRetAny = mxInvocation->getValue( pProp->GetName() ); // take over the value from Uno to Sbx unoToSbxValue( pVar, aRetAny ); - if( pParams && bCanBeConsideredAMethod ) - pVar->SetParameters( nullptr ); - } catch( const Exception& ) {