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 364169 26f3802831da367ae6e03db59928f03904bc3f7a
parent 363870 e5a10bc7dac4ee2453d8319165c1f6578203eac7
child 364170 c089d5ef5c2342f03c557c6be87871e3da14169b
push id17375
push usergsquelart@mozilla.com
push dateFri, 06 May 2016 02:13: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()
 {