Avoid a crash if the LogFile cannot be opened.

This commit is contained in:
Andrea Odetti 2021-04-18 18:11:53 +01:00
parent 1314fcc0ed
commit 5966fa5138

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));