From dfc2e9be0948ca72f858197392921f5bb27f605b Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 19 Mar 2018 16:31:38 +0000 Subject: ofz#7012 Integer-overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and fix negative rounding code, which results in changing tet of from -996 to -1002 which is closer to the original -1000 Change-Id: Ie992e61bf4d14d0cd4194e773479feba96b6d68e Reviewed-on: https://gerrit.libreoffice.org/51576 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- oox/source/drawingml/drawingmltypes.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'oox/source') diff --git a/oox/source/drawingml/drawingmltypes.cxx b/oox/source/drawingml/drawingmltypes.cxx index cda9c1c61817..93c7c423330f 100644 --- a/oox/source/drawingml/drawingmltypes.cxx +++ b/oox/source/drawingml/drawingmltypes.cxx @@ -90,14 +90,18 @@ float GetTextSize( const OUString& sValue ) sal_Int32 GetTextSpacingPoint( const OUString& sValue ) { sal_Int32 nRet; - if( ::sax::Converter::convertNumber( nRet, sValue ) ) + if( ::sax::Converter::convertNumber( nRet, sValue, (SAL_MIN_INT32 + 360) / 254, (SAL_MAX_INT32 - 360) / 254 ) ) nRet = GetTextSpacingPoint( nRet ); return nRet; } -sal_Int32 GetTextSpacingPoint( const sal_Int32 nValue ) +sal_Int32 GetTextSpacingPoint(sal_Int32 nValue) { - return ( nValue * 254 + 360 ) / 720; + if (nValue > 0) + nValue = (nValue * 254 + 360); + else if (nValue < 0) + nValue = (nValue * 254 - 360); + return nValue / 720; } float GetFontHeight( sal_Int32 nHeight ) -- cgit