Skip to content

Commit 608c8ec

Browse files
authored
fix regression of null pointer deref
1 parent 40c769b commit 608c8ec

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

search.cpp

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,32 +49,33 @@ namespace engine
4949
session.seldepth = std::max(session.seldepth, ply);
5050
uint64_t hash = board.hash();
5151
Move preferred = Move::none();
52-
if (TTEntry *entry = search::tt.lookup(hash);entry->getDepth() >= depth)
53-
{
54-
Value ttScore = entry->getScore();
55-
TTFlag flag = entry->getFlag();
56-
57-
if (flag == TTFlag::EXACT)
58-
{
59-
session.pv[ply][0] = Move(entry->getMove());
60-
session.pv[ply][1] = Move::none();
61-
return ttScore;
62-
}
63-
64-
if (flag == TTFlag::LOWERBOUND && ttScore >= beta)
65-
{
66-
session.pv[ply][0] = Move(entry->getMove());
67-
session.pv[ply][1] = Move::none();
68-
return ttScore;
69-
}
70-
71-
if (flag == TTFlag::UPPERBOUND && ttScore <= alpha)
72-
{
73-
session.pv[ply][0] = Move(entry->getMove());
74-
session.pv[ply][1] = Move::none();
75-
return ttScore;
76-
}
77-
}
52+
if (TTEntry *entry = search::tt.lookup(hash))
53+
if (entry->getDepth() >= depth)
54+
{
55+
Value ttScore = entry->getScore();
56+
TTFlag flag = entry->getFlag();
57+
58+
if (flag == TTFlag::EXACT)
59+
{
60+
session.pv[ply][0] = Move(entry->getMove());
61+
session.pv[ply][1] = Move::none();
62+
return ttScore;
63+
}
64+
65+
if (flag == TTFlag::LOWERBOUND && ttScore >= beta)
66+
{
67+
session.pv[ply][0] = Move(entry->getMove());
68+
session.pv[ply][1] = Move::none();
69+
return ttScore;
70+
}
71+
72+
if (flag == TTFlag::UPPERBOUND && ttScore <= alpha)
73+
{
74+
session.pv[ply][0] = Move(entry->getMove());
75+
session.pv[ply][1] = Move::none();
76+
return ttScore;
77+
}
78+
}
7879
if (depth == 0)
7980
{
8081
session.nodes++;

0 commit comments

Comments
 (0)