tools/source/datetime/duration.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
New commits: commit a00f59131c5493855f48aa0bec6eb0d0a6dc85a3 Author: Julien Nabet <serval2...@yahoo.fr> AuthorDate: Mon Jun 19 10:10:42 2023 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Mon Jun 19 20:17:26 2023 +0200 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 <sberg...@redhat.com> (cherry picked from commit 99d01ff26fe69ccc66f49b3ddd43b258c3687f2c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153277 Reviewed-by: Eike Rathke <er...@redhat.com> 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) {