Avoid crashing on Log File opening
[stockfish] / src / misc.cpp
index 17644eed89545d88071b18e6795bb895f7df35dc..6f908fd2730bb61cc3645449886616ac0e9a5e54 100644 (file)
@@ -102,6 +102,13 @@ public:
     if (!fname.empty() && !l.file.is_open())
     {
         l.file.open(fname, ifstream::out);
+
+        if (!l.file.is_open())
+        {
+            cerr << "Unable to open debug log file " << fname << endl;
+            exit(EXIT_FAILURE);
+        }
+
         cin.rdbuf(&l.in);
         cout.rdbuf(&l.out);
     }