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

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: 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
Index: runtime/vm/os_macos.cc
diff --git a/runtime/vm/os_macos.cc b/runtime/vm/os_macos.cc
index a7ea2f04f3446c0a8b7c94edcd60dba96f279121..0204fa18af9e34956fde2b1ca9ce8506c08604b5 100644
--- a/runtime/vm/os_macos.cc
+++ b/runtime/vm/os_macos.cc
@@ -29,17 +29,16 @@ 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);
+ return succeeded ? static_cast<int>(decomposed.tm_gmtoff) : 0;
}
« runtime/vm/os_android.cc ('K') | « 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