Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(959)

Unified Diff: src/platform-posix.cc

Issue 160451: Guard local time posix functions from NaN value of invalid dates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/platform-nullos.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-posix.cc
===================================================================
--- src/platform-posix.cc (revision 2600)
+++ src/platform-posix.cc (working copy)
@@ -86,16 +86,20 @@
}
-char* OS::LocalTimezone(double time) {
+const char* OS::LocalTimezone(double time) {
+ ASSERT(!isnan(time));
time_t tv = static_cast<time_t>(floor(time/msPerSecond));
struct tm* t = localtime(&tv);
- return const_cast<char*>(t->tm_zone);
+ if (NULL == t) return "";
+ return t->tm_zone;
}
double OS::DaylightSavingsOffset(double time) {
+ ASSERT(!isnan(time));
time_t tv = static_cast<time_t>(floor(time/msPerSecond));
struct tm* t = localtime(&tv);
+ if (NULL == t) return nan_value();
return t->tm_isdst > 0 ? 3600 * msPerSecond : 0;
}
« no previous file with comments | « src/platform-nullos.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698