msvcrt: Restore error handling code in localtime

Dmitry Timoshkov dmitry at codeweavers.com
Tue Aug 21 07:44:24 CDT 2007


Hello,

Changelog:
    msvcrt: Restore error handling code in localtime.

---
 dlls/msvcrt/time.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c
index 4d75fb9..69762e0 100644
--- a/dlls/msvcrt/time.c
+++ b/dlls/msvcrt/time.c
@@ -105,10 +105,14 @@ MSVCRT_time_t CDECL MSVCRT_mktime(struct MSVCRT_tm *mstm)
 struct MSVCRT_tm* CDECL MSVCRT_localtime(const MSVCRT_time_t* secs)
 {
     struct tm tm;
-    thread_data_t *data = msvcrt_get_thread_data();
+    thread_data_t *data;
     time_t seconds = *secs;
 
-    localtime_r( &seconds, &tm );
+    if (seconds < 0) return NULL;
+
+    if (!localtime_r( &seconds, &tm )) return NULL;
+
+    data = msvcrt_get_thread_data();
     unix_tm_to_msvcrt( &data->time_buffer, &tm );
 
     return &data->time_buffer;
-- 
1.5.2.5






More information about the wine-patches mailing list