failsafe for localtime(-1) on Windows to avoid segfault

This commit is contained in:
Andrew Tonner 2020-02-12 16:13:26 -08:00
parent 7c61312974
commit 07e9db881c

View File

@ -133,6 +133,13 @@ uint32 TimeToMacTime(time_t t)
// This code is taken from glibc 2.2 // This code is taken from glibc 2.2
// Convert to number of seconds elapsed since 1-Jan-1904 // Convert to number of seconds elapsed since 1-Jan-1904
#ifdef WIN32
if (t == -1) {
// failsafe as this will segfault
return 0;
}
#endif
struct tm *local = localtime(&t); struct tm *local = localtime(&t);
const int TM_EPOCH_YEAR = 1900; const int TM_EPOCH_YEAR = 1900;
const int MAC_EPOCH_YEAR = 1904; const int MAC_EPOCH_YEAR = 1904;