Skip to content

Commit

Permalink
fix segfault when using -learn with -g (board source)
Browse files Browse the repository at this point in the history
This was caused by index out of bounds because when the game comes from file, we don't have moves info
  • Loading branch information
panstromek committed Feb 20, 2022
1 parent 902d35e commit 2c13087
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions learn.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "osfbook.h"
#include "patterns.h"
#include "search.h"
#include "error.h"
#include "timer.h"


Expand Down Expand Up @@ -151,6 +152,9 @@ learn_game( int game_length, int private_game, int save_database ) {
side_to_move = OPP( side_to_move );
generate_all( side_to_move );
}
if (game_move[i] == -1) {
fatal_error("Cannot learn game. Missing move no. %d", i);
}
(void) make_move( side_to_move, game_move[i], TRUE );
if ( side_to_move == WHITESQ )
game_move[i] = -game_move[i];
Expand Down

0 comments on commit 2c13087

Please sign in to comment.