From fcee83810a5bcf774d3e13cf9e65ccf3b29e3319 Mon Sep 17 00:00:00 2001 From: Jake Senne <26696846+w1wwwwww@users.noreply.github.com> Date: Tue, 3 Jan 2023 15:16:45 -0600 Subject: [PATCH] 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 --- AUTHORS | 1 + src/syzygy/tbprobe.cpp | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/AUTHORS b/AUTHORS index 70b500ea..998399b9 100644 --- a/AUTHORS +++ b/AUTHORS @@ -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) diff --git a/src/syzygy/tbprobe.cpp b/src/syzygy/tbprobe.cpp index b7ba3240..cc5e2852 100644 --- a/src/syzygy/tbprobe.cpp +++ b/src/syzygy/tbprobe.cpp @@ -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; -- 2.39.2