From c65d035cc94af8487ae51fd7f26ad53a3588beec Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 9 May 2019 01:14:46 +0900 Subject: [PATCH] clock: Bug fix: Use float64 not to overflow Bug: #862 --- internal/clock/now_windows.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/clock/now_windows.go b/internal/clock/now_windows.go index 5b23cb25f..7f5799b2e 100644 --- a/internal/clock/now_windows.go +++ b/internal/clock/now_windows.go @@ -58,5 +58,7 @@ var ( func now() int64 { // Use the time duration instead of the current counter to avoid overflow. duration := queryPerformanceCounter() - initCtr - return (duration * 1e9) / freq + + // Use float64 not to overflow int64 values (#862). + return int64(float64(duration) / float64(freq) * 1e9) }