tools/source/datetime/ttime.cxx |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 7fa9b09bc271d91792fe78c5cb03430bf38155a8
Author:     Urja Rannikko <urja...@gmail.com>
AuthorDate: Sun Dec 5 14:29:09 2021 +0200
Commit:     Jan-Marek Glogowski <glo...@fbihome.de>
CommitDate: Mon Dec 6 11:58:09 2021 +0100

    tdf#128715 fix tools::Time::GetMonotonicTicks() on 32-bit linux
    
    Since time_t and thus tv_sec is (still, for now) 32-bit on these
    architechtures, the multiplication of seconds to microseconds
    happened in 32-bit thus causing a rollover roughly every 4295 seconds.
    Fix by casting tv_sec to sal_uInt64 before the multiplication.
    
    Also fixes tdf#144975.
    
    Change-Id: I829d3406208545a816979cb58daaeb99ec2d5294
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126379
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de>

diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx
index c6c89c934886..ee9e427205ef 100644
--- a/tools/source/datetime/ttime.cxx
+++ b/tools/source/datetime/ttime.cxx
@@ -477,11 +477,12 @@ sal_uInt64 tools::Time::GetMonotonicTicks()
 #if defined(_POSIX_TIMERS)
     struct timespec currentTime;
     clock_gettime( CLOCK_MONOTONIC, &currentTime );
-    nMicroSeconds = currentTime.tv_sec * 1000 * 1000 + currentTime.tv_nsec / 
1000;
+    nMicroSeconds
+        = static_cast<sal_uInt64>(currentTime.tv_sec) * 1000 * 1000 + 
currentTime.tv_nsec / 1000;
 #else
     struct timeval currentTime;
     gettimeofday( &currentTime, nullptr );
-    nMicroSeconds = currentTime.tv_sec * 1000 * 1000 + currentTime.tv_usec;
+    nMicroSeconds = static_cast<sal_uInt64>(currentTime.tv_sec) * 1000 * 1000 
+ currentTime.tv_usec;
 #endif
 #endif // __MACH__
     return nMicroSeconds;

Reply via email to