From c5e9ac7590d39e6928add8559ed8ff44434a2ad7 Mon Sep 17 00:00:00 2001 From: r3inbowari Date: Sat, 11 Nov 2023 22:21:51 +0800 Subject: [PATCH] fix: unexpected division by a zero-length vector in stddeviation --- speedtest/request.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/speedtest/request.go b/speedtest/request.go index b9020e3..661514c 100644 --- a/speedtest/request.go +++ b/speedtest/request.go @@ -387,6 +387,9 @@ func checkSum(data []byte) uint16 { } func StandardDeviation(vector []int64) (mean, variance, stdDev, min, max int64) { + if len(vector) == 0 { + return + } var sumNum, accumulate int64 min = math.MaxInt64 max = math.MinInt64