mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 09:37:16 +08:00
Properly set to zero stuff returned by 'new'
Language guarantees that c'tor is called, but without any c'tor it happens to work by accident because OS zeroes out the freshly allocated pages. The problem is that if I deallocate and allocate again, the second time pages are no more newly come by the OS and so could contain stale info. A practical case could be if we change TT size or numbers of threads on the fly while already running. Bug spotted by Justin Blanchard. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -146,6 +146,7 @@ MaterialInfoTable::MaterialInfoTable() {
|
||||
<< " bytes for material hash table." << endl;
|
||||
Application::exit_with_failure();
|
||||
}
|
||||
memset(entries, 0, MaterialTableSize * sizeof(MaterialInfo));
|
||||
}
|
||||
|
||||
MaterialInfoTable::~MaterialInfoTable() {
|
||||
|
||||
Reference in New Issue
Block a user