summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2023-06-19 10:10:42 +0200
committerEike Rathke <erack@redhat.com>2023-06-19 20:17:26 +0200
commita00f59131c5493855f48aa0bec6eb0d0a6dc85a3 (patch)
treeefac6aac52cf6ecaf3f52d4cbce15b05d93d8784 /tools
parent7ab377a2f38ea447995ecc2a1703fd820fa1cb8a (diff)
Fix TB Jenkins_Linux_Ubsan (duration.cxx)
/tools/source/datetime/duration.cxx:190:77: runtime error: negation of -2147483648 cannot be represented in type 'sal_Int32' (aka 'int'); cast to an unsigned type to negate this value to itself 0 0x7f08bd84936d in tools::Duration::Mult(int, bool&) const /tools/source/datetime/duration.cxx:190:77 1 0x7f08c1c1d27a in tools::DurationTest::testDuration() /tools/qa/cppunit/test_duration.cxx:219:26 Detected thanks to eac63ab120a181a1dff6317ee3d223327080e992 Related: tdf#153517 Introduce class tools::Duration Change-Id: I3804cc4ff4011a7f3b393b82b27f0c805682fbb4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153254 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com> (cherry picked from commit 99d01ff26fe69ccc66f49b3ddd43b258c3687f2c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153277 Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/datetime/duration.cxx6
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/source/datetime/duration.cxx b/tools/source/datetime/duration.cxx
index 07f79929177f..7140e2b99579 100644
--- a/tools/source/datetime/duration.cxx
+++ b/tools/source/datetime/duration.cxx
@@ -187,8 +187,10 @@ Duration Duration::Mult(sal_Int32 nMult, bool& rbOverflow) const
if (o3tl::checked_multiply(static_cast<sal_uInt64>(maTime.GetHour()), nMult64, nH))
break;
sal_uInt64 nD;
- if (o3tl::checked_multiply(static_cast<sal_uInt64>(mnDays < 0 ? -mnDays : mnDays),
- nMult64, nD))
+ if (o3tl::checked_multiply(
+ mnDays < 0 ? static_cast<sal_uInt64>(-static_cast<sal_Int64>(mnDays))
+ : static_cast<sal_uInt64>(mnDays),
+ nMult64, nD))
break;
if (nN > Time::nanoSecPerSec)
{