Bug 992512 - DOMStorageCache crashes (sDatabase access violation read), r=smaug, a=lsblakk
authorHonza Bambas <honzab.moz@firemni.cz>
Mon, 28 Apr 2014 12:41:29 +0200
changeset 193177 041d2a2ee631fb6d830c47a372c4a066731ca111
parent 193176 178fdf135b37c899754dacc519c5dd1afc981930
child 193178 92eb6a82595cb1c3cdf7270fab341e1b36cf9933
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, lsblakk
bugs992512
milestone30.0a2
Bug 992512 - DOMStorageCache crashes (sDatabase access violation read), r=smaug, a=lsblakk
dom/src/storage/DOMStorageCache.cpp
--- a/dom/src/storage/DOMStorageCache.cpp
+++ b/dom/src/storage/DOMStorageCache.cpp
@@ -491,16 +491,20 @@ DOMStorageCache::SetItem(const DOMStorag
 
   if (aValue == aOld && DOMStringIsNull(aValue) == DOMStringIsNull(aOld)) {
     return NS_SUCCESS_DOM_NO_OPERATION;
   }
 
   data.mKeys.Put(aKey, aValue);
 
   if (Persist(aStorage)) {
+    if (!sDatabase) {
+      return NS_ERROR_NOT_INITIALIZED;
+    }
+
     if (DOMStringIsNull(aOld)) {
       return sDatabase->AsyncAddItem(this, aKey, aValue);
     }
 
     return sDatabase->AsyncUpdateItem(this, aKey, aValue);
   }
 
   return NS_OK;
@@ -526,16 +530,20 @@ DOMStorageCache::RemoveItem(const DOMSto
   }
 
   // Recalculate the cached data size
   const int64_t delta = -(static_cast<int64_t>(aOld.Length()));
   unused << ProcessUsageDelta(aStorage, delta);
   data.mKeys.Remove(aKey);
 
   if (Persist(aStorage)) {
+    if (!sDatabase) {
+      return NS_ERROR_NOT_INITIALIZED;
+    }
+
     return sDatabase->AsyncRemoveItem(this, aKey);
   }
 
   return NS_OK;
 }
 
 nsresult
 DOMStorageCache::Clear(const DOMStorage* aStorage)
@@ -562,16 +570,20 @@ DOMStorageCache::Clear(const DOMStorage*
   bool hadData = !!data.mKeys.Count();
 
   if (hadData) {
     unused << ProcessUsageDelta(aStorage, -data.mOriginQuotaUsage);
     data.mKeys.Clear();
   }
 
   if (Persist(aStorage) && (refresh || hadData)) {
+    if (!sDatabase) {
+      return NS_ERROR_NOT_INITIALIZED;
+    }
+
     return sDatabase->AsyncClear(this);
   }
 
   return hadData ? NS_OK : NS_SUCCESS_DOM_NO_OPERATION;
 }
 
 void
 DOMStorageCache::CloneFrom(const DOMStorageCache* aThat)