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

Unified Diff: runtime/vm/os_macos.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_linux.cc ('k') | runtime/vm/os_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/os_macos.cc
diff --git a/runtime/vm/os_macos.cc b/runtime/vm/os_macos.cc
index a7ea2f04f3446c0a8b7c94edcd60dba96f279121..94470b508e9a50eeb46279c63318f9cea518817c 100644
--- a/runtime/vm/os_macos.cc
+++ b/runtime/vm/os_macos.cc
@@ -29,17 +29,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_linux.cc ('k') | runtime/vm/os_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698