Bug 1167423 - patch 7 - Handle return values of FallibleTArray functions in DataStore API, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 25 May 2015 12:50:15 +0100
changeset 245468 f75a03f1e8b22ebb17263e60062eb3999c5cbdfe
parent 245467 5bc009d443048a17e876ea1d4cf311da29736ac0
child 245469 02d0f71e3b768c1f18a9708092deabf099f9e4a3
push id28806
push userphilringnalda@gmail.com
push dateTue, 26 May 2015 02:10:16 +0000
treeherdermozilla-central@4362d9251296 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1167423
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1167423 - patch 7 - Handle return values of FallibleTArray functions in DataStore API, r=smaug
dom/datastore/DataStoreDB.cpp
dom/datastore/DataStoreService.cpp
--- a/dom/datastore/DataStoreDB.cpp
+++ b/dom/datastore/DataStoreDB.cpp
@@ -311,17 +311,19 @@ DataStoreDB::DatabaseOpened()
     new VersionChangeListener(mDatabase);
   rv = mDatabase->EventTarget::AddEventListener(
     NS_LITERAL_STRING("versionchange"), listener, false);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   StringOrStringSequence objectStores;
-  objectStores.RawSetAsStringSequence().AppendElements(mObjectStores);
+  if (!objectStores.RawSetAsStringSequence().AppendElements(mObjectStores)) {
+    return NS_ERROR_OUT_OF_MEMORY;
+  }
 
   nsRefPtr<IDBTransaction> txn;
   error = mDatabase->Transaction(objectStores,
                                  mTransactionMode,
                                  getter_AddRefs(txn));
   if (NS_WARN_IF(error.Failed())) {
     return error.StealNSResult();
   }
--- a/dom/datastore/DataStoreService.cpp
+++ b/dom/datastore/DataStoreService.cpp
@@ -1353,17 +1353,19 @@ DataStoreService::CreateFirstRevisionId(
   MOZ_ASSERT(NS_IsMainThread());
 
   nsRefPtr<DataStoreDB> db = new DataStoreDB(aManifestURL, aName);
 
   nsRefPtr<FirstRevisionIdCallback> callback =
     new FirstRevisionIdCallback(aAppId, aName, aManifestURL);
 
   Sequence<nsString> dbs;
-  dbs.AppendElement(NS_LITERAL_STRING(DATASTOREDB_REVISION));
+  if (!dbs.AppendElement(NS_LITERAL_STRING(DATASTOREDB_REVISION))) {
+    return NS_ERROR_OUT_OF_MEMORY;
+  }
 
   return db->Open(IDBTransactionMode::Readwrite, dbs, callback);
 }
 
 nsresult
 DataStoreService::EnableDataStore(uint32_t aAppId, const nsAString& aName,
                                   const nsAString& aManifestURL)
 {