Don't crash if we get a timezone change notification on an uninitialized isolate
authorjochen@chromium.org <jochen@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 28 Mar 2014 08:59:25 +0000 (08:59 +0000)
committerjochen@chromium.org <jochen@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 28 Mar 2014 08:59:25 +0000 (08:59 +0000)
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
src/date.cc

index 5dcf592..f7da5ed 100644 (file)
@@ -5710,6 +5710,7 @@ double v8::Date::ValueOf() const {
 
 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) {
   i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+  if (!i_isolate->IsInitialized()) return;
   ON_BAILOUT(i_isolate, "v8::Date::DateTimeConfigurationChangeNotification()",
              return);
   LOG_API(i_isolate, "Date::DateTimeConfigurationChangeNotification");
index 70d6be9..c22bc76 100644 (file)
@@ -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) {