2008-07-16  Ariya Hidayat  <ariya.hidayat@trolltech.com>

        Reviewed by Simon.

        http://trolltech.com/developer/task-tracker/index_html?method=entry&id=216179
        Fix potential crash (on Qt for Windows port) when performing JavaScript date
        conversion.

        * kjs/DateMath.cpp:
        (KJS::getLocalTime): For the Qt port, prefer to use Windows code, i.e.
        localtime_s() instead of localtime() since the latter might crash (on Windows)
        given a non-sensible, e.g. NaN, argument.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@35198 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/kjs/DateMath.cpp b/JavaScriptCore/kjs/DateMath.cpp
index 2cefa74..60fa2a1 100644
--- a/JavaScriptCore/kjs/DateMath.cpp
+++ b/JavaScriptCore/kjs/DateMath.cpp
@@ -309,17 +309,17 @@
 
 void getLocalTime(const time_t* localTime, struct tm* localTM)
 {
-#if PLATFORM(QT)
+#if PLATFORM(WIN_OS)
+#if COMPILER(MSVC7)
+    *localTM = *localtime(localTime);
+#else
+    localtime_s(localTM, localTime);
+#endif
+#elif PLATFORM(QT)
 #if USE(MULTIPLE_THREADS)
-#error Mulitple threads are currently not supported in the Qt/mingw build
+#error Multiple threads are currently not supported in the Qt/mingw build
 #endif
     *localTM = *localtime(localTime);
-#elif PLATFORM(WIN_OS)
-    #if COMPILER(MSVC7)
-    *localTM = *localtime(localTime);
-    #else
-    localtime_s(localTM, localTime);
-    #endif
 #else
     localtime_r(localTime, localTM);
 #endif