Fix an out-of-bound array access in simulator.TestClear()

This commit is contained in:
Jakub Tużnik 2020-11-17 13:54:52 +01:00
parent f18b65a80c
commit 6821ab8f90
2 changed files with 6 additions and 2 deletions

View File

@ -53,6 +53,10 @@ func createTestPods(n int) []*apiv1.Pod {
}
func assignPodsToNodes(pods []*apiv1.Pod, nodes []*apiv1.Node) {
if len(nodes) == 0 {
return
}
j := 0
for i := 0; i < len(pods); i++ {
if j >= len(nodes) {

View File

@ -240,8 +240,8 @@ func TestClear(t *testing.T) {
// Run with -count=1 to avoid caching.
localRand := rand.New(rand.NewSource(time.Now().Unix()))
nodeCount := localRand.Intn(100)
podCount := localRand.Intn(1000)
nodeCount := localRand.Intn(99) + 1
podCount := localRand.Intn(999) + 1
extraNodeCount := localRand.Intn(100)
extraPodCount := localRand.Intn(1000)