Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix wrong assert.
can trigger an abort when compiling with debug=yes, and using 7men TB.
The assert should check that less than 8 pieces are in the key for each
side, matching the assumption that underlies the FEN string construction.
Also take explicitly care of a 'v' character in material strings.

Fixes an issue reported in the forum:
https://groups.google.com/d/msg/fishcooking/yoVC7etIpz0/7mS7ntZMBAAJ

closes #2547

No functional change.
  • Loading branch information
vondele committed Feb 10, 2020
1 parent 0c878ad commit 0aee1ec
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/position.cpp
Expand Up @@ -375,11 +375,13 @@ void Position::set_state(StateInfo* si) const {

Position& Position::set(const string& code, Color c, StateInfo* si) {

assert(code.length() > 0 && code.length() < 8);
assert(code[0] == 'K');

string sides[] = { code.substr(code.find('K', 1)), // Weak
code.substr(0, code.find('K', 1)) }; // Strong
code.substr(0, std::min(code.find('v'), code.find('K', 1))) }; // Strong

assert(sides[0].length() > 0 && sides[0].length() < 8);
assert(sides[1].length() > 0 && sides[1].length() < 8);

std::transform(sides[c].begin(), sides[c].end(), sides[c].begin(), tolower);

Expand Down

0 comments on commit 0aee1ec

Please sign in to comment.