Skip to content

Commit 715dd83

Browse files
committed
Fix a possible division by zero if too close from a mirror
1 parent ff9fb8a commit 715dd83

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

selection.go

+5
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ func (h DefaultEngine) Selection(ctx *Context, cache *Cache, fileInfo *FileInfo,
119119
return
120120
}
121121

122+
// We're not interested in divisions by zero
123+
if closestMirror == 0 {
124+
closestMirror = math.SmallestNonzeroFloat32
125+
}
126+
122127
/* Weight distribution for random selection [Probabilistic weight] */
123128

124129
// Compute score for each mirror and return the mirrors eligible for weight distribution.

version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
var (
12-
VERSION = "0.1.1"
12+
VERSION = "0.1.2"
1313
)
1414

1515
func printVersion() {

0 commit comments

Comments
 (0)