Bug 1339734 - dom/media should check the return value of OriginKeysTable::GetPrincipalKey, r=jesup
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 15 Feb 2017 18:47:23 +0100
changeset 343113 47e3f088c240f1a1ea816bdfa75603b36b9c9995
parent 343112 7045bd028af07881543111c6ac822d5f13882cfd
child 343114 5fecf76b34f833ae9e878468d4137d043d30f5e6
push id31369
push userkwierso@gmail.com
push dateThu, 16 Feb 2017 00:18:40 +0000
treeherdermozilla-central@e9b926463f9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1339734
milestone54.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 1339734 - dom/media should check the return value of OriginKeysTable::GetPrincipalKey, r=jesup
dom/media/systemservices/MediaParent.cpp
--- a/dom/media/systemservices/MediaParent.cpp
+++ b/dom/media/systemservices/MediaParent.cpp
@@ -57,18 +57,18 @@ class OriginKeyStore : public nsISupport
   };
 
   class OriginKeysTable
   {
   public:
     OriginKeysTable() : mPersistCount(0) {}
 
     nsresult
-    GetPrincipalKey(const ipc::PrincipalInfo& aPrincipalInfo, nsCString& aResult,
-                    bool aPersist = false)
+    GetPrincipalKey(const ipc::PrincipalInfo& aPrincipalInfo,
+                    nsCString& aResult, bool aPersist = false)
     {
       nsAutoCString principalString;
       PrincipalInfoToString(aPrincipalInfo, principalString);
 
       OriginKey* key;
       if (!mKeys.Get(principalString, &key)) {
         nsCString salt; // Make a new one
         nsresult rv = GenerateRandomName(salt, key->EncodedLength);
@@ -168,17 +168,22 @@ class OriginKeyStore : public nsISupport
   public:
     OriginKeysLoader() {}
 
     nsresult
     GetPrincipalKey(const ipc::PrincipalInfo& aPrincipalInfo,
                     nsCString& aResult, bool aPersist = false)
     {
       auto before = mPersistCount;
-      OriginKeysTable::GetPrincipalKey(aPrincipalInfo, aResult, aPersist);
+      nsresult rv = OriginKeysTable::GetPrincipalKey(aPrincipalInfo, aResult,
+                                                     aPersist);
+      if (NS_WARN_IF(NS_FAILED(rv))) {
+        return rv;
+      }
+
       if (mPersistCount != before) {
         Save();
       }
       return NS_OK;
     }
 
     already_AddRefed<nsIFile>
     GetFile()
@@ -452,25 +457,29 @@ Parent<Super>::RecvGetPrincipalKey(const
   MOZ_ASSERT(sts);
   RefPtr<Parent<Super>> that(this);
 
   rv = sts->Dispatch(NewRunnableFrom([this, that, id, profileDir,
                                       aPrincipalInfo, aPersist]() -> nsresult {
     MOZ_ASSERT(!NS_IsMainThread());
     mOriginKeyStore->mOriginKeys.SetProfileDir(profileDir);
 
+    nsresult rv;
     nsAutoCString result;
     if (IsPincipalInfoPrivate(aPrincipalInfo)) {
-      mOriginKeyStore->mPrivateBrowsingOriginKeys.GetPrincipalKey(aPrincipalInfo, result);
+      rv = mOriginKeyStore->mPrivateBrowsingOriginKeys.GetPrincipalKey(aPrincipalInfo, result);
     } else {
-      mOriginKeyStore->mOriginKeys.GetPrincipalKey(aPrincipalInfo, result, aPersist);
+      rv = mOriginKeyStore->mOriginKeys.GetPrincipalKey(aPrincipalInfo, result, aPersist);
+    }
+
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
     }
 
     // Pass result back to main thread.
-    nsresult rv;
     rv = NS_DispatchToMainThread(NewRunnableFrom([this, that, id,
                                                   result]() -> nsresult {
       if (mDestroyed) {
         return NS_OK;
       }
       RefPtr<Pledge<nsCString>> p = mOutstandingPledges.Remove(id);
       if (!p) {
         return NS_ERROR_UNEXPECTED;