1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-06-27 16:09:52 +00:00

Only close file if already open

Ensures that the tablebase file is only closed if already open.

Fixes #4268
Closes https://github.com/official-stockfish/Stockfish/pull/4321

No functional change
This commit is contained in:
Jake Senne 2023-01-03 15:16:45 -06:00 committed by Joost VandeVondele
parent 4101893a28
commit fcee83810a
2 changed files with 4 additions and 6 deletions

View file

@ -92,6 +92,7 @@ Ivan Ivec (IIvec)
Jacques B. (Timshel)
Jan Ondruš (hxim)
Jared Kish (Kurtbusch, kurt22i)
Jake Senne (w1wwwwww)
Jarrod Torriero (DU-jdto)
Jean Gauthier (OuaisBla)
Jean-Francois Romang (jromang)

View file

@ -199,13 +199,10 @@ public:
}
}
// Memory map the file and check it. File should be already open and will be
// closed after mapping.
// Memory map the file and check it.
uint8_t* map(void** baseAddress, uint64_t* mapping, TBType type) {
assert(is_open());
close(); // Need to re-open to get native file descriptor
if (is_open())
close(); // Need to re-open to get native file descriptor
#ifndef _WIN32
struct stat statbuf;