diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2023-06-19 10:10:42 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2023-06-19 13:56:21 +0200 |
commit | 99d01ff26fe69ccc66f49b3ddd43b258c3687f2c (patch) | |
tree | a829caa0e5b74022d8d59cf10b6525de452ee9cf /tools | |
parent | 2afff27c5327bcb30f894d9a507131f2ad8f1dc6 (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>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/datetime/duration.cxx | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/source/datetime/duration.cxx b/tools/source/datetime/duration.cxx index c8cb4616eb08..be51a6e95e0f 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) { |