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

Unified Diff: runtime/vm/os_linux.cc

Issue 11267051: Updated GetTimeZoneName() to return "" if localtime_r fails or has a NULL for its tm_zone value, li… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review feedback: added parens, comments. Created 8 years, 2 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 | « runtime/vm/os_android.cc ('k') | runtime/vm/os_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/os_linux.cc
diff --git a/runtime/vm/os_linux.cc b/runtime/vm/os_linux.cc
index 0d67d1450ff430d87942c10e0b3661edb89f6004..a33effe8d2cf6449111576eee79d49a8470ad2f7 100644
--- a/runtime/vm/os_linux.cc
+++ b/runtime/vm/os_linux.cc
@@ -28,17 +28,17 @@ static bool LocalTime(int64_t seconds_since_epoch, tm* tm_result) {
const char* OS::GetTimeZoneName(int64_t seconds_since_epoch) {
tm decomposed;
bool succeeded = LocalTime(seconds_since_epoch, &decomposed);
- ASSERT(succeeded);
- return decomposed.tm_zone;
+ // If unsuccessful, return an empty string like V8 does.
+ return (succeeded && (decomposed.tm_zone != NULL)) ? decomposed.tm_zone : "";
}
int OS::GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch) {
tm decomposed;
bool succeeded = LocalTime(seconds_since_epoch, &decomposed);
- ASSERT(succeeded);
// Even if the offset was 24 hours it would still easily fit into 32 bits.
- return static_cast<int>(decomposed.tm_gmtoff);
+ // If unsuccessful, return zero like V8 does.
+ return succeeded ? static_cast<int>(decomposed.tm_gmtoff) : 0;
}
« no previous file with comments | « runtime/vm/os_android.cc ('k') | runtime/vm/os_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698