[Libreoffice-commits] core.git: stoc/source
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Wed Aug 14 06:59:16 UTC 2019
stoc/source/typeconv/convert.cxx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit b122db670b2b3d68f0ba199a1e25bdb1d8992241
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Aug 13 20:59:58 2019 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed Aug 14 08:58:22 2019 +0200
Reformulate TypeConverter_Impl::toHyper FLOAT/DOUBLE cases
...to avoid UB when fVal was cast to nRet *before* checking that fVal actually
fit into the bounds, and to avoid Clang 10
-Werror,-Wimplicit-int-float-conversion when comparing fVal against
SAL_MAX_INT64 ("implicit conversion from 'const sal_Int64' (aka 'const long') to
'double' changes value from 9223372036854775807 to 9223372036854775808")
Change-Id: I9e2f6c97309609d9ec2455d4ecf9c341d85c1680
Reviewed-on: https://gerrit.libreoffice.org/77430
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/stoc/source/typeconv/convert.cxx b/stoc/source/typeconv/convert.cxx
index 9ffef7287d6c..b74a3d1a5714 100644
--- a/stoc/source/typeconv/convert.cxx
+++ b/stoc/source/typeconv/convert.cxx
@@ -313,9 +313,9 @@ sal_Int64 TypeConverter_Impl::toHyper( const Any& rAny, sal_Int64 min, sal_uInt6
case TypeClass_FLOAT:
{
double fVal = round( *o3tl::forceAccess<float>(rAny) );
- nRet = (fVal > SAL_MAX_INT64 ? static_cast<sal_Int64>(static_cast<sal_uInt64>(fVal)) : static_cast<sal_Int64>(fVal));
if (fVal >= min && fVal <= max)
{
+ nRet = (fVal >= 0.0 ? static_cast<sal_Int64>(static_cast<sal_uInt64>(fVal)) : static_cast<sal_Int64>(fVal));
return nRet;
}
throw CannotConvertException(
@@ -325,9 +325,9 @@ sal_Int64 TypeConverter_Impl::toHyper( const Any& rAny, sal_Int64 min, sal_uInt6
case TypeClass_DOUBLE:
{
double fVal = round( *o3tl::forceAccess<double>(rAny) );
- nRet = (fVal > SAL_MAX_INT64 ? static_cast<sal_Int64>(static_cast<sal_uInt64>(fVal)) : static_cast<sal_Int64>(fVal));
if (fVal >= min && fVal <= max)
{
+ nRet = (fVal >= 0.0 ? static_cast<sal_Int64>(static_cast<sal_uInt64>(fVal)) : static_cast<sal_Int64>(fVal));
return nRet;
}
throw CannotConvertException(
More information about the Libreoffice-commits
mailing list