]> git.sesse.net Git - stockfish/commitdiff
Only close file if already open
authorJake Senne <26696846+w1wwwwww@users.noreply.github.com>
Tue, 3 Jan 2023 21:16:45 +0000 (15:16 -0600)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Mon, 9 Jan 2023 19:16:17 +0000 (20:16 +0100)
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
src/syzygy/tbprobe.cpp

diff --git a/AUTHORS b/AUTHORS
index 70b500ea79edc2168e2d04d50004516cceaa9627..998399b969dbb5cbc3494ea8dfb05f6b6e4664ca 100644 (file)
--- 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)
index b7ba32407456f810b0354c4bc920d8c5c839fdfb..cc5e2852a09106d2c4b2a051cc5be6f61710d378 100644 (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;