From 7419fc569f07fbd5685a6e58439b681a52fdd045 Mon Sep 17 00:00:00 2001 From: Alin Andrei Abahnencei Date: Mon, 23 Dec 2024 10:56:39 +0200 Subject: tdf#154285 Check upper bound of arguments in SbRtl_Hour function Signed-off-by: Alin Andrei Abahnencei Change-Id: Ib372b4dfde77961e7982bd0d8f1f8598be7da726 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179252 Reviewed-by: Mike Kaganski Tested-by: Jenkins --- basic/source/runtime/methods.cxx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'basic') diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 0c2b7c298cae..899a79cd90d5 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -2042,16 +2042,11 @@ sal_Int16 implGetHour( double dDate ) void SbRtl_Hour(StarBASIC *, SbxArray & rPar, bool) { - if (rPar.Count() < 2) - { - StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); - } - else - { - double nArg = rPar.Get(1)->GetDate(); - sal_Int16 nHour = implGetHour( nArg ); - rPar.Get(0)->PutInteger(nHour); - } + if (rPar.Count() != 2) + return StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); + double nArg = rPar.Get(1)->GetDate(); + sal_Int16 nHour = implGetHour( nArg ); + rPar.Get(0)->PutInteger(nHour); } void SbRtl_Minute(StarBASIC *, SbxArray & rPar, bool) -- cgit