diff --git a/compat/localtime_r.c b/compat/localtime_r.c index cc202655e9..91dc60d7c1 100644 --- a/compat/localtime_r.c +++ b/compat/localtime_r.c @@ -37,7 +37,11 @@ struct tm *localtime_r (const time_t *timep, struct tm *result) #if (__STDC_WANT_LIB_EXT1__) return localtime_s(timep, result); #elif defined (_WIN32) - return ((errno = localtime_s(result, timep)) == 0) ? result : NULL; + errno_t ret = localtime_s(result, timep); + if (ret == 0) + return result; + errno = ret; + return NULL; #else # warning localtime_r() not implemented! return gmtime_r(timep, result);