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
--- 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;