Bug 1134387: Prevent crash when decoder couldn't be created. r=edwin a=lmandel
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 27 Feb 2015 11:31:46 +1100
changeset 250226 1ef0bf557169
parent 250225 a7098648876a
child 250227 9745aeeb920c
push id4521
push usercpearce@mozilla.com
push date2015-03-04 01:22 +0000
treeherdermozilla-beta@8abdbdecd2d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin, lmandel
bugs1134387
milestone37.0
Bug 1134387: Prevent crash when decoder couldn't be created. r=edwin a=lmandel
dom/media/DecoderTraits.cpp
dom/media/mediasource/MediaSourceReader.cpp
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -650,16 +650,19 @@ DecoderTraits::CreateDecoder(const nsACS
   return decoder.forget();
 }
 
 /* static */
 MediaDecoderReader* DecoderTraits::CreateReader(const nsACString& aType, AbstractMediaDecoder* aDecoder)
 {
   MediaDecoderReader* decoderReader = nullptr;
 
+  if (!aDecoder) {
+    return decoderReader;
+  }
 #ifdef MOZ_FMP4
   if (IsMP4SupportedType(aType)) {
     decoderReader = new MP4Reader(aDecoder);
   } else
 #endif
 #ifdef MOZ_GSTREAMER
   if (IsGStreamerSupportedType(aType)) {
     decoderReader = new GStreamerReader(aDecoder);
--- a/dom/media/mediasource/MediaSourceReader.cpp
+++ b/dom/media/mediasource/MediaSourceReader.cpp
@@ -597,17 +597,17 @@ CreateReaderForType(const nsACString& aT
 {
 #ifdef MOZ_FMP4
   // The MP4Reader that supports fragmented MP4 and uses
   // PlatformDecoderModules is hidden behind prefs for regular video
   // elements, but we always want to use it for MSE, so instantiate it
   // directly here.
   if ((aType.LowerCaseEqualsLiteral("video/mp4") ||
        aType.LowerCaseEqualsLiteral("audio/mp4")) &&
-      MP4Decoder::IsEnabled()) {
+      MP4Decoder::IsEnabled() && aDecoder) {
     return new MP4Reader(aDecoder);
   }
 #endif
   return DecoderTraits::CreateReader(aType, aDecoder);
 }
 
 already_AddRefed<SourceBufferDecoder>
 MediaSourceReader::CreateSubDecoder(const nsACString& aType, int64_t aTimestampOffset)