mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1127554 - Make MP4Sample::Pad fallible. v1 r=mattwoodrow
This commit is contained in:
parent
5314527fbc
commit
9092b791ba
@ -88,7 +88,12 @@ FFmpegAudioDecoder<LIBAV_VER>::DecodePacket(MP4Sample* aSample)
|
||||
AVPacket packet;
|
||||
av_init_packet(&packet);
|
||||
|
||||
aSample->Pad(FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!aSample->Pad(FF_INPUT_BUFFER_PADDING_SIZE)) {
|
||||
NS_WARNING("FFmpeg audio decoder failed to allocate sample.");
|
||||
mCallback->Error();
|
||||
return;
|
||||
}
|
||||
|
||||
packet.data = aSample->data;
|
||||
packet.size = aSample->size;
|
||||
|
||||
|
@ -54,7 +54,12 @@ FFmpegH264Decoder<LIBAV_VER>::DoDecodeFrame(mp4_demuxer::MP4Sample* aSample)
|
||||
av_init_packet(&packet);
|
||||
|
||||
mp4_demuxer::AnnexB::ConvertSampleToAnnexB(aSample);
|
||||
aSample->Pad(FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!aSample->Pad(FF_INPUT_BUFFER_PADDING_SIZE)) {
|
||||
NS_WARNING("FFmpeg h264 decoder failed to allocate sample.");
|
||||
mCallback->Error();
|
||||
return DecodeResult::DECODE_ERROR;
|
||||
}
|
||||
|
||||
packet.data = aSample->data;
|
||||
packet.size = aSample->size;
|
||||
packet.dts = aSample->decode_timestamp;
|
||||
|
@ -254,7 +254,7 @@ MP4Sample::Update(int64_t& aMediaTime)
|
||||
crypto.Update(m);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
MP4Sample::Pad(size_t aPaddingBytes)
|
||||
{
|
||||
size_t newSize = size + aPaddingBytes;
|
||||
@ -263,7 +263,10 @@ MP4Sample::Pad(size_t aPaddingBytes)
|
||||
// not then we copy to a new buffer.
|
||||
uint8_t* newData = mMediaBuffer && newSize <= mMediaBuffer->size()
|
||||
? data
|
||||
: new uint8_t[newSize];
|
||||
: new (fallible) uint8_t[newSize];
|
||||
if (!newData) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memset(newData + size, 0, aPaddingBytes);
|
||||
|
||||
@ -275,6 +278,8 @@ MP4Sample::Pad(size_t aPaddingBytes)
|
||||
mMediaBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -158,7 +158,7 @@ public:
|
||||
virtual ~MP4Sample();
|
||||
MP4Sample* Clone() const;
|
||||
void Update(int64_t& aMediaTime);
|
||||
void Pad(size_t aPaddingBytes);
|
||||
bool Pad(size_t aPaddingBytes);
|
||||
|
||||
stagefright::MediaBuffer* mMediaBuffer;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user