Bug 1266336 - Check sCDMWrapper before creating video decoder - r?cpearce
Ensure that there is a CDM before creating a video decoder that relies on that
CDM. This is mainly to prevent using the Widevine video decoder alone, without
decryption.
MozReview-Commit-ID: 7p49CnmV2r7
--- a/dom/media/gmp/widevine-adapter/WidevineAdapter.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineAdapter.cpp
@@ -119,17 +119,23 @@ WidevineAdapter::GMPGetAPI(const char* a
decryptor->SetCDM(RefPtr<CDMWrapper>(sCDMWrapper));
cdm->Initialize(false, /* allow_distinctive_identifier */
false /* allow_persistent_state */);
*aPluginAPI = decryptor;
} else if (!strcmp(aAPIName, GMP_API_VIDEO_DECODER)) {
- *aPluginAPI = new WidevineVideoDecoder(static_cast<GMPVideoHost*>(aHostAPI), RefPtr<CDMWrapper>(sCDMWrapper));
+ if (!sCDMWrapper) {
+ Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p No cdm for video decoder",
+ aAPIName, aHostAPI, aPluginAPI, this);
+ return GMPGenericErr;
+ }
+ *aPluginAPI = new WidevineVideoDecoder(static_cast<GMPVideoHost*>(aHostAPI),
+ RefPtr<CDMWrapper>(sCDMWrapper));
}
return *aPluginAPI ? GMPNoErr : GMPNotImplementedErr;
}
void
WidevineAdapter::GMPShutdown()
{