Kaydet (Commit) 7ee3953c authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz#3819 Integer-overflow

Change-Id: Ic45692152b039c0ee2f5659d7739c3a2517c5e83
Reviewed-on: https://gerrit.libreoffice.org/43876Tested-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 6b760dc4
......@@ -514,8 +514,9 @@ namespace emfio
// must later be made portable in SV (KA 1996-02-08)
Size aFontSize = ImplMap (rFont.GetFontSize(), false);
if( aFontSize.Height() < 0 )
aFontSize.Height() *= -1;
const auto nHeight = aFontSize.Height();
if (nHeight < 0)
aFontSize.Height() = o3tl::saturating_toggle_sign(nHeight);
rFont.SetFontSize( aFontSize );
......
......@@ -56,6 +56,15 @@ typename std::enable_if<std::is_unsigned<T>::value, T>::type saturating_add(
}
}
template<typename T> inline
typename std::enable_if<std::is_signed<T>::value, T>::type saturating_toggle_sign(
T a)
{
if (a == std::numeric_limits<T>::min())
return std::numeric_limits<T>::max();
return a * -1;
}
#if defined(_MSC_VER)
template<typename T> inline bool checked_multiply(T a, T b, T& result)
......
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