Bug 1266336 - Check actual CDM creation - r?cpearce draft
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 05 May 2016 12:04:07 +1000
changeset 363597 85eeca137e23e8e7ed627f76ae833ea5072ab766
parent 363596 5c181dec3a42f82de0013608a04dcefd78acc0ca
child 363598 580fbc559efc08fb80856f5c7cc4e7bb6e4bcd03
push id17255
push usergsquelart@mozilla.com
push dateThu, 05 May 2016 04:47:52 +0000
reviewerscpearce
bugs1266336
milestone49.0a1
Bug 1266336 - Check actual CDM creation - r?cpearce Check the return result from Widevine's CDM creation function, and handle failure. MozReview-Commit-ID: HYvKgdK53aQ
dom/media/gmp/widevine-adapter/WidevineAdapter.cpp
--- a/dom/media/gmp/widevine-adapter/WidevineAdapter.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineAdapter.cpp
@@ -96,29 +96,34 @@ WidevineAdapter::GMPGetAPI(const char* a
     if (sCDMWrapper) {
       // We only support one CDM instance per GMP process. Fail!
       Log("WidevineAdapter::GMPGetAPI() Tried to create more than once CDM per process! FAIL!");
       return GMPQuotaExceededErr;
     }
     auto create = reinterpret_cast<decltype(::CreateCdmInstance)*>(
       PR_FindFunctionSymbol(mLib, "CreateCdmInstance"));
     if (!create) {
-      Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p FAILED to create cdm",
+      Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p FAILED to find CreateCdmInstance",
         aAPIName, aHostAPI, aPluginAPI, this);
       return GMPGenericErr;
     }
 
     WidevineDecryptor* decryptor = new WidevineDecryptor();
 
     auto cdm = reinterpret_cast<cdm::ContentDecryptionModule*>(
       create(cdm::ContentDecryptionModule::kVersion,
              WidevineKeySystem,
              strlen(WidevineKeySystem),
              &GetCdmHost,
              decryptor));
+    if (!cdm) {
+      Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p FAILED to create cdm",
+          aAPIName, aHostAPI, aPluginAPI, this);
+      return GMPGenericErr;
+    }
     Log("cdm: 0x%x", cdm);
     sCDMWrapper = new CDMWrapper(cdm);
     decryptor->SetCDM(RefPtr<CDMWrapper>(sCDMWrapper));
 
     cdm->Initialize(false, /* allow_distinctive_identifier */
                     false /* allow_persistent_state */);
 
     *aPluginAPI = decryptor;