Skip to content

Commit 57c6256

Browse files
committed
ensure array access is not out of bounds
1 parent 5c8b7de commit 57c6256

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pyoptsparse/pyNSGA2/source/tourselect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void selection (population *old_pop, population *new_pop, Global global, int *nr
3232
a2[rand] = a2[i];
3333
a2[i] = temp;
3434
}
35-
for (i=0; i<global.popsize; i+=4)
35+
for (i=0; i<global.popsize-4; i+=4)
3636
{
3737
parent1 = tournament (&old_pop->ind[a1[i]], &old_pop->ind[a1[i+1]], global);
3838
parent2 = tournament (&old_pop->ind[a1[i+2]], &old_pop->ind[a1[i+3]], global);

0 commit comments

Comments
 (0)