Skip to content

Commit 2c13087

Browse files
committed
fix segfault when using -learn with -g (board source)
This was caused by index out of bounds because when the game comes from file, we don't have moves info
1 parent 902d35e commit 2c13087

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

learn.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "osfbook.h"
2727
#include "patterns.h"
2828
#include "search.h"
29+
#include "error.h"
2930
#include "timer.h"
3031

3132

@@ -151,6 +152,9 @@ learn_game( int game_length, int private_game, int save_database ) {
151152
side_to_move = OPP( side_to_move );
152153
generate_all( side_to_move );
153154
}
155+
if (game_move[i] == -1) {
156+
fatal_error("Cannot learn game. Missing move no. %d", i);
157+
}
154158
(void) make_move( side_to_move, game_move[i], TRUE );
155159
if ( side_to_move == WHITESQ )
156160
game_move[i] = -game_move[i];

0 commit comments

Comments
 (0)