From 03d2502cc6fb4859bbb951dbec299d87d1b27311 Mon Sep 17 00:00:00 2001 From: kanjitalk755 Date: Sun, 26 Nov 2017 16:22:52 +0900 Subject: [PATCH] fixed: localtime() may return NULL --- SheepShaver/src/macos_util.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SheepShaver/src/macos_util.cpp b/SheepShaver/src/macos_util.cpp index bb33ace5..8dbc5013 100644 --- a/SheepShaver/src/macos_util.cpp +++ b/SheepShaver/src/macos_util.cpp @@ -324,7 +324,9 @@ uint32 TimeToMacTime(time_t t) // This code is taken from glibc 2.2 // Convert to number of seconds elapsed since 1-Jan-1904 - struct tm *local = localtime(&t); + struct tm result; + localtime_r(&t, &result); + struct tm *local = &result; const int TM_EPOCH_YEAR = 1900; const int MAC_EPOCH_YEAR = 1904; int a4 = ((local->tm_year + TM_EPOCH_YEAR) >> 2) - !(local->tm_year & 3);