Kaydet (Commit) 3e38f8c5 authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz#4591 Integer-overflow

Change-Id: I97d527272f198a46485b98a8f26acd8daa42cab7
Reviewed-on: https://gerrit.libreoffice.org/46217Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 8d62b79f
......@@ -29,6 +29,7 @@
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <com/sun/star/style/TabAlign.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <o3tl/safeint.hxx>
#include <oox/dllapi.h>
#include <oox/helper/helper.hxx>
#include <rtl/ustring.hxx>
......@@ -180,7 +181,7 @@ inline sal_Int64 convertHmmToEmu( sal_Int32 nValue )
inline sal_Int32 convertEmuToHmm( sal_Int64 nValue )
{
sal_Int32 nCorrection = (nValue > 0 ? 1 : -1) * EMU_PER_HMM / 2; // So that the implicit floor will round.
return getLimitedValue< sal_Int32, sal_Int64 >( (nValue + nCorrection) / EMU_PER_HMM, SAL_MIN_INT32, SAL_MAX_INT32 );
return getLimitedValue<sal_Int32, sal_Int64>(o3tl::saturating_add<sal_Int64>(nValue, nCorrection) / EMU_PER_HMM, SAL_MIN_INT32, SAL_MAX_INT32);
}
/** Converts the passed 64-bit integer value from EMUs to Points. */
......
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