sc/source/core/tool/interpr2.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
New commits: commit 2606915f0f480af30367a5d0f67adbf930c2c6b9 Author: Stephan Bergmann <sberg...@redhat.com> Date: Mon Jun 20 09:54:14 2016 +0200 Avoid undefined behavior when converting from double to sal_Int16 Change-Id: Iced9d25a15f25076b1c23b064eabfe5f0899882c diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 812c858..c9a73d4 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -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) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits