summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2020-08-26 18:56:28 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2020-08-27 15:49:16 +0200
commit781b6ac998370f2923c0783100da7086bfad622d (patch)
treeee911c33d57c5eace6b86d55b38d72d357cc76ab /basic
parent0c28fc7d89e833860216bb02d787d004c32595c7 (diff)
tdf#136143 - reset SbxFlagBits::Fixed SbiRuntime::StepPARAM
In order to prevent type conversion errors, reset a variable of type SbxERROR to not fixed. Variable will be of type SbxERROR, but can be converted to any requested type. Change-Id: Ic856376e3f8232577a5e894a2adb2545c8723033 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101419 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'basic')
-rw-r--r--basic/qa/basic_coverage/test_ismissing_cascade.vb51
-rw-r--r--basic/source/runtime/runtime.cxx2
2 files changed, 53 insertions, 0 deletions
diff --git a/basic/qa/basic_coverage/test_ismissing_cascade.vb b/basic/qa/basic_coverage/test_ismissing_cascade.vb
new file mode 100644
index 000000000000..ad967c7bbd81
--- /dev/null
+++ b/basic/qa/basic_coverage/test_ismissing_cascade.vb
@@ -0,0 +1,51 @@
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+ result = verify_testIsMissingCascade()
+ If failCount <> 0 Or passCount = 0 Then
+ doUnitTest = 0
+ Else
+ doUnitTest = 1
+ End If
+End Function
+
+Function verify_testIsMissingCascade() As String
+
+ passCount = 0
+ failCount = 0
+
+ result = "Test Results" & Chr$(10) & "============" & Chr$(10)
+ testName = "Test missing (IsMissing with cascading optionals)"
+ On Error GoTo errorHandler
+
+ ' tdf#136143 - test cascading optionals in order to prevent type conversion errors, because
+ ' optional arguments are of type SbxERROR and set to not fixed.
+ TestLog_ASSERT TestOpt(), 2, "Cascading optionals"
+
+ result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+ verify_testIsMissingCascade = result
+
+ Exit Function
+errorHandler:
+ TestLog_ASSERT False, True, Err.Description
+End Function
+
+Function TestOpt(Optional A)
+ TestOpt = TestOptCascade(A)
+End Function
+
+Function TestOptCascade(Optional A)
+ If IsMissing(A) Then A = 2
+ TestOptCascade = A
+End Function
+
+Sub TestLog_ASSERT(actual As Variant, expected As Integer, testName As String)
+ If expected = actual Then
+ passCount = passCount + 1
+ Else
+ result = result & Chr$(10) & " Failed: " & testName & " returned " & actual & ", expected " & expected
+ failCount = failCount + 1
+ End If
+End Sub \ No newline at end of file
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index f55d5ad86bd8..abd65aa685a8 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -4110,6 +4110,8 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 )
const SbxParamInfo* pParam = pInfo->GetParam( nIdx );
if( pParam && ( pParam->nFlags & SbxFlagBits::Optional ) )
{
+ // tdf#136143 - reset SbxFlagBits::Fixed in order to prevent type conversion errors
+ pVar->ResetFlag( SbxFlagBits::Fixed );
// Default value?
sal_uInt16 nDefaultId = static_cast<sal_uInt16>(pParam->nUserData & 0x0ffff);
if( nDefaultId > 0 )