From 6781deae0aab9732b59a54082a3748ed59be7fa0 Mon Sep 17 00:00:00 2001 From: "jochen@chromium.org" Date: Fri, 28 Mar 2014 08:59:25 +0000 Subject: [PATCH] Don't crash if we get a timezone change notification on an uninitialized isolate Also make the date cache's timestamp more robust. BUG=357362 R=svenpanne@chromium.org LOG=y Review URL: https://codereview.chromium.org/216613003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20323 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/api.cc | 1 + src/date.cc | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api.cc b/src/api.cc index 5dcf592296..f7da5ed01a 100644 --- a/src/api.cc +++ b/src/api.cc @@ -5710,6 +5710,7 @@ double v8::Date::ValueOf() const { void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { i::Isolate* i_isolate = reinterpret_cast(isolate); + if (!i_isolate->IsInitialized()) return; ON_BAILOUT(i_isolate, "v8::Date::DateTimeConfigurationChangeNotification()", return); LOG_API(i_isolate, "Date::DateTimeConfigurationChangeNotification"); diff --git a/src/date.cc b/src/date.cc index 70d6be989f..c22bc76673 100644 --- a/src/date.cc +++ b/src/date.cc @@ -49,9 +49,10 @@ static const char kDaysInMonths[] = void DateCache::ResetDateCache() { static const int kMaxStamp = Smi::kMaxValue; - stamp_ = Smi::FromInt(stamp_->value() + 1); - if (stamp_->value() > kMaxStamp) { + if (stamp_->value() >= kMaxStamp) { stamp_ = Smi::FromInt(0); + } else { + stamp_ = Smi::FromInt(stamp_->value() + 1); } ASSERT(stamp_ != Smi::FromInt(kInvalidStamp)); for (int i = 0; i < kDSTSize; ++i) {