Bug 143582 - The return value of Basic function is not initialized when called by the invoke method
Summary: The return value of Basic function is not initialized when called by the invo...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.1.4.2 release
Hardware: All All
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:7.3.0 target:7.2.1 target:7.1....
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-28 11:43 UTC by Vladimir Sokolinskiy
Modified: 2022-02-11 04:52 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Sokolinskiy 2021-07-28 11:43:48 UTC
Description:
The return value of Basic function is not initialized when called by the invoke method

Steps to Reproduce:
Insert the next script into module Module1 of library Standard of any Calc document.

Option Explicit
Function ConcatArray(arr) As String
  Dim v
  For Each v In arr
    ConcatArray=ConcatArray & v
  Next v
End Function

Sub Test1
  Msgbox ConcatArray(Array("a", "b"))
  Msgbox ConcatArray(Array("c", "d"))
End Sub

Sub Test2
  Dim script
  script = ThisComponent.scriptProvider.getScript("vnd.sun.star.script:Standard.Module1.ConcatArray?language=Basic&location=document")
  Msgbox script.invoke(Array(Array("a", "b")), Array(), Array())
  Msgbox script.invoke(Array(Array("c", "d")), Array(), Array())  
End Sub


Actual Results:
Run "Test1". It shows
ab
cd

Then run "Test2". It shows
cdab
cdabcd

Expected Results:
Test2 MUST show
ab
cd


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 Mike Kaganski 2021-07-28 14:39:43 UTC
Repro.

XScript::invoke [1] is documented to return "the value returned from the function being invoked". It doesn't mention "... and keep a copy to attach to the next return as a bonus" ;-D

[1] https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1script_1_1provider_1_1XScript.html#a11a551f5a2520f74c5109cd8c9f8c7b7
Comment 2 Andreas Heinisch 2021-07-28 15:08:54 UTC
Repro in:
Version: 6.2.5.2 (x64)
Build-ID: 1ec314fa52f458adc18c4f025c545a4e8b22c159
CPU-Threads: 4; BS: Windows 10.0; UI-Render: Standard; VCL: win; 
Gebietsschema: de-DE (de_DE); UI-Sprache: de-DE
Calc: threaded
Comment 3 Commit Notification 2021-08-03 22:17:59 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/24d24debef4cda7de702c4b470a3707f1aae3ea3

tdf#143582 - Clear return value of the method before calling it

It will be available in 7.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 4 Vladimir Sokolinskiy 2021-08-04 10:00:00 UTC
Thank you, Andreas!
Comment 5 Commit Notification 2021-08-09 15:38:17 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

https://git.libreoffice.org/core/commit/cb97358ab845f13f1c57b410e59126f20652d552

tdf#143582 - Clear return value of the method before calling it

It will be available in 7.2.1.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2021-08-09 17:42:53 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "libreoffice-7-1":

https://git.libreoffice.org/core/commit/c2697c468c1441df61b2d590a7cb259d21b3ba60

tdf#143582 - Clear return value of the method before calling it

It will be available in 7.1.6.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2021-12-22 15:40:23 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/822998f1dc202aba7a558767f641687aef0c1148

tdf#143582: Avoid error on clearing leftover return value of a method

It will be available in 7.4.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Commit Notification 2021-12-23 20:31:29 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/29ec800034211194f9e2ab1748e0b6a1011dcf3f

tdf#143582: Avoid error on clearing leftover return value of a method

It will be available in 7.3.0.2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.