using double to avoild multplication overflow (dotnet/corefx#38079)
authorAnirudh Agnihotry <anirudhagnihotry098@gmail.com>
Fri, 31 May 2019 15:17:45 +0000 (08:17 -0700)
committerGitHub <noreply@github.com>
Fri, 31 May 2019 15:17:45 +0000 (08:17 -0700)
Commit migrated from https://github.com/dotnet/corefx/commit/655be420da4094ffed95ffa661a37225a3d7c6c9

src/libraries/Native/Unix/System.Native/pal_time.c

index 1b126678fe7c1e4440674fb13f75830291ae1967..1a7c862749d1e17da319e128caaa63a4cb5a7295 100644 (file)
@@ -169,7 +169,7 @@ int32_t SystemNative_GetCpuUtilization(ProcessCpuInformation* previousCpuInfo)
     uint64_t resolution = SystemNative_GetTimestampResolution();
     uint64_t timestamp = SystemNative_GetTimestamp();
 
-    uint64_t currentTime = timestamp * SecondsToNanoSeconds / resolution;
+    uint64_t currentTime = (uint64_t)(timestamp * ((double)SecondsToNanoSeconds / resolution));
 
     uint64_t lastRecordedCurrentTime = previousCpuInfo->lastRecordedCurrentTime;
     uint64_t lastRecordedKernelTime = previousCpuInfo->lastRecordedKernelTime;