Skip to content

Commit 95bca20

Browse files
committed
initialize best_index to zero in nega_scout (it causes ub if the depth is 0)
1 parent 5a4a717 commit 95bca20

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

osfbook.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ nega_scout( int depth, int allow_mpc, int side_to_move,
12261226
/* First determine the best move in the current position
12271227
and its score when searched to depth DEPTH.
12281228
This is done using standard negascout with iterative deepening. */
1229-
1229+
*best_index = 0; // in case the depth is 0, we have to initialize it somehow. Maybe random index would be better than 0.
12301230
for ( curr_depth = 2 - (depth % 2); curr_depth <= depth; curr_depth += 2 ) {
12311231
low_score = -INFINITE_EVAL;
12321232
curr_alpha = -INFINITE_EVAL;

0 commit comments

Comments
 (0)