From 8a19b6772ae1410966f3c573c60e74a1c938615d Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Thu, 9 Apr 2015 21:14:56 +1000 Subject: [PATCH] Bug 1150853: Part3. Do not modify provided extradata array. r=edwin The extradata provided may be modified elsewhere, prevent potential conflict. --- dom/media/fmp4/ffmpeg/FFmpegAudioDecoder.cpp | 4 +++- dom/media/fmp4/ffmpeg/FFmpegDataDecoder.cpp | 6 +++--- dom/media/fmp4/ffmpeg/FFmpegH264Decoder.cpp | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/dom/media/fmp4/ffmpeg/FFmpegAudioDecoder.cpp b/dom/media/fmp4/ffmpeg/FFmpegAudioDecoder.cpp index 383fd3a6673e..31fcde2ea83d 100644 --- a/dom/media/fmp4/ffmpeg/FFmpegAudioDecoder.cpp +++ b/dom/media/fmp4/ffmpeg/FFmpegAudioDecoder.cpp @@ -22,7 +22,9 @@ FFmpegAudioDecoder::FFmpegAudioDecoder( , mCallback(aCallback) { MOZ_COUNT_CTOR(FFmpegAudioDecoder); - mExtraData = aConfig.audio_specific_config; + // Use a new DataBuffer as the object will be modified during initialization. + mExtraData = new DataBuffer; + mExtraData->AppendElements(*aConfig.audio_specific_config); } nsresult diff --git a/dom/media/fmp4/ffmpeg/FFmpegDataDecoder.cpp b/dom/media/fmp4/ffmpeg/FFmpegDataDecoder.cpp index 9a0ab0a5f88d..7b9133d23754 100644 --- a/dom/media/fmp4/ffmpeg/FFmpegDataDecoder.cpp +++ b/dom/media/fmp4/ffmpeg/FFmpegDataDecoder.cpp @@ -96,9 +96,9 @@ FFmpegDataDecoder::Init() if (mExtraData) { mCodecContext->extradata_size = mExtraData->Length(); - for (int i = 0; i < FF_INPUT_BUFFER_PADDING_SIZE; i++) { - mExtraData->AppendElement(0); - } + // FFmpeg may use SIMD instructions to access the data which reads the + // data in 32 bytes block. Must ensure we have enough data to read. + mExtraData->AppendElements(FF_INPUT_BUFFER_PADDING_SIZE); mCodecContext->extradata = mExtraData->Elements(); } else { mCodecContext->extradata_size = 0; diff --git a/dom/media/fmp4/ffmpeg/FFmpegH264Decoder.cpp b/dom/media/fmp4/ffmpeg/FFmpegH264Decoder.cpp index 541314444370..815a9cd15022 100644 --- a/dom/media/fmp4/ffmpeg/FFmpegH264Decoder.cpp +++ b/dom/media/fmp4/ffmpeg/FFmpegH264Decoder.cpp @@ -32,7 +32,9 @@ FFmpegH264Decoder::FFmpegH264Decoder( , mDisplayHeight(aConfig.display_height) { MOZ_COUNT_CTOR(FFmpegH264Decoder); - mExtraData = aConfig.extra_data; + // Use a new DataBuffer as the object will be modified during initialization. + mExtraData = new DataBuffer; + mExtraData->AppendElements(*aConfig.extra_data); } nsresult