Kaydet (Commit) 2606915f authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Avoid undefined behavior when converting from double to sal_Int16

Change-Id: Iced9d25a15f25076b1c23b064eabfe5f0899882c
üst 8f56d408
......@@ -305,7 +305,14 @@ void ScInterpreter::ScEasterSunday()
if ( MustHaveParamCount( GetByte(), 1 ) )
{
sal_Int16 nDay, nMonth, nYear;
nYear = (sal_Int16) ::rtl::math::approxFloor( GetDouble() );
double x = rtl::math::approxFloor( GetDouble() );
if (x <= sal_Int32(SAL_MIN_INT16) - 1
|| x >= sal_Int32(SAL_MAX_INT16) + 1)
{
PushIllegalArgument();
return;
}
nYear = static_cast<sal_Int16>(x);
if ( nYear < 100 )
nYear = pFormatter->ExpandTwoDigitYear( nYear );
if (nYear < 1583 || nYear > 9956)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment