tdf#151503 - Do not evaluate a missing optional variable to a boolean
Change-Id: I671f857344f91de63612eabcbbdb2cab9b94cc0d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141296 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
This commit is contained in:
parent
aa451a4230
commit
bdfcad586d
3 changed files with 38 additions and 0 deletions
|
@ -125,6 +125,12 @@ Sub verify_testOptionalsBasic()
|
|||
' - Actual : 448 (Actual value of the variable)
|
||||
TestUtil.AssertEqual(TestObjectError, 449, "TestObjectError")
|
||||
|
||||
' tdf#151503 - error handling of missing optional parameters (boolean operations)
|
||||
' Without the fix in place, this test would have failed with:
|
||||
' - Expected: 449 (ERRCODE_BASIC_NOT_OPTIONAL - Argument not optional)
|
||||
' - Actual : 0 (No error code since a missing parameter evaluates to true)
|
||||
TestUtil.AssertEqual(TestBooleanOperations, 449, "TestBooleanOperations")
|
||||
|
||||
Exit Sub
|
||||
errorHandler:
|
||||
TestUtil.ReportErrorHandler("verify_testOptionalsBasic", Err, Error$, Erl)
|
||||
|
@ -229,6 +235,15 @@ errorHandler:
|
|||
TestObjectError = Err()
|
||||
End Function
|
||||
|
||||
Function TestBooleanOperations(Optional optBool As Boolean)
|
||||
On Error GoTo errorHandler
|
||||
if optBool then
|
||||
TestBooleanOperations = 0
|
||||
end if
|
||||
errorHandler:
|
||||
TestBooleanOperations = Err()
|
||||
End Function
|
||||
|
||||
Function CollectionSum(C)
|
||||
Dim idx As Integer
|
||||
CollectionSum = 0
|
||||
|
|
|
@ -127,6 +127,12 @@ Sub verify_testOptionalsCompatible()
|
|||
' - Actual : 448 (Actual value of the variable)
|
||||
TestUtil.AssertEqual(TestObjectError, 449, "TestObjectError")
|
||||
|
||||
' tdf#151503 - error handling of missing optional parameters (boolean operations)
|
||||
' Without the fix in place, this test would have failed with:
|
||||
' - Expected: 449 (ERRCODE_BASIC_NOT_OPTIONAL - Argument not optional)
|
||||
' - Actual : 0 (No error code since a missing parameter evaluates to true)
|
||||
TestUtil.AssertEqual(TestBooleanOperations, 449, "TestBooleanOperations")
|
||||
|
||||
Exit Sub
|
||||
errorHandler:
|
||||
TestUtil.ReportErrorHandler("verify_testOptionalsCompatible", Err, Error$, Erl)
|
||||
|
@ -231,6 +237,15 @@ errorHandler:
|
|||
TestObjectError = Err()
|
||||
End Function
|
||||
|
||||
Function TestBooleanOperations(Optional optBool As Boolean)
|
||||
On Error GoTo errorHandler
|
||||
if optBool then
|
||||
TestBooleanOperations = 0
|
||||
end if
|
||||
errorHandler:
|
||||
TestBooleanOperations = Err()
|
||||
End Function
|
||||
|
||||
Function CollectionSum(C)
|
||||
Dim idx As Integer
|
||||
CollectionSum = 0
|
||||
|
|
|
@ -3022,6 +3022,14 @@ bool SbiRuntime::EvaluateTopOfStackAsBool()
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// tdf#151503 - do not evaluate a missing optional variable to a boolean
|
||||
if (tos->GetType() == SbxERROR && IsMissing(tos.get(), 1))
|
||||
{
|
||||
Error(ERRCODE_BASIC_NOT_OPTIONAL);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( tos->IsObject() )
|
||||
{
|
||||
//GetBool applied to an Object attempts to dereference and evaluate
|
||||
|
|
Loading…
Reference in a new issue