mirror of
https://github.com/moonlight-stream/Internet-Hosting-Tool.git
synced 2026-10-27 14:39:58 +00:00
Redirect stdout to NUL if the log file can't be opened
This commit is contained in:
1 parent
771e34f199
commit
8f011440b4
2 files changed
+6
-2
No files matched your search
+1
-1
Submodule GS-IPv6-Forwarder updated: 41ab166b8a...48c0136b9d.
+5
-1
@@ -842,7 +842,11 @@ void ResetLogFile(bool standaloneExe)
|
|||||||
MoveFileExA(currentLogFilePath, oldLogFilePath, MOVEFILE_REPLACE_EXISTING);
|
MoveFileExA(currentLogFilePath, oldLogFilePath, MOVEFILE_REPLACE_EXISTING);
|
||||||
|
|
||||||
// Redirect stdout to this new file
|
// Redirect stdout to this new file
|
||||||
freopen(currentLogFilePath, "w", stdout);
|
if (freopen(currentLogFilePath, "w", stdout) == NULL) {
|
||||||
|
// If we couldn't create a log file, just redirect stdout to NUL.
|
||||||
|
// We have to open _something_ or printf() will crash.
|
||||||
|
freopen("NUL", "w", stdout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print a log header
|
// Print a log header
|
||||||
|
|||||||
Reference in new issue
Block a user