Skip to content

Commit f80f866

Browse files
committed
fix buffer overflows found by fuzzer
1 parent 497a237 commit f80f866

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

midgame.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ middle_game( int side_to_move, int max_depth,
13661366

13671367
/* Update the stored scores */
13681368

1369-
if ( (!stage_reached[base_stage + depth] || full_length_line) &&
1369+
if ((base_stage + depth > 0 && base_stage + depth < 62) && (!stage_reached[base_stage + depth] || full_length_line) &&
13701370
update_evals ) {
13711371
stage_reached[base_stage + depth] = TRUE;
13721372
if ( side_to_move == BLACKSQ )
@@ -1378,7 +1378,7 @@ middle_game( int side_to_move, int max_depth,
13781378
/* Adjust the eval for oscillations odd/even by simply averaging the
13791379
last two stages (if they are available). */
13801380

1381-
if ( stage_reached[base_stage + depth] &&
1381+
if ((base_stage + depth > 0 && base_stage + depth < 62) && stage_reached[base_stage + depth] &&
13821382
stage_reached[base_stage + depth - 1] && update_evals ) {
13831383
if ( side_to_move == BLACKSQ )
13841384
adjusted_val = (stage_score[base_stage + depth] +

search.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void
9999
inherit_move_lists( int stage ) {
100100
int i;
101101
int last;
102-
if(stage >= 61) {
102+
if(stage >= 61 || stage < 0) {
103103
return;
104104
}
105105
if ( list_inherited[stage] )

0 commit comments

Comments
 (0)