Avoid a crash if the LogFile cannot be opened. (PR #944)

This commit is contained in:
Andrea 2021-04-23 20:49:31 +01:00 committed by GitHub
parent 41778aa472
commit 9bec2ce405
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,6 +48,12 @@ void LogInit(void)
return;
g_fh = fopen(LOG_FILENAME, "a+t"); // Open log file (append & text mode)
if (!g_fh)
{
LogOutput("Failed to open logfile '%s'\n", LOG_FILENAME);
return;
}
setvbuf(g_fh, NULL, _IONBF, 0); // No buffering (so implicit fflush after every fprintf)
CHAR aDateStr[80], aTimeStr[80];
GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, (LPTSTR)aDateStr, sizeof(aDateStr));