Bug 1266336 - Check sCDMWrapper before creating video decoder - r?cpearce draft
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 05 May 2016 11:37:22 +1000
changeset 363596 5c181dec3a42f82de0013608a04dcefd78acc0ca
parent 363286 369a5ee3a2880a4a98df3a00bf3db8d8f36b181b
child 363597 85eeca137e23e8e7ed627f76ae833ea5072ab766
push id17255
push usergsquelart@mozilla.com
push dateThu, 05 May 2016 04:47:52 +0000
reviewerscpearce
bugs1266336
milestone49.0a1
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
dom/media/gmp/widevine-adapter/WidevineAdapter.cpp
--- 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()
 {