Bug 1296533: [ogg] P2. Fix memory leak in OggReader. r?gerald
MozReview-Commit-ID: J47DoZddn7E
--- a/dom/media/ogg/OggReader.cpp
+++ b/dom/media/ogg/OggReader.cpp
@@ -126,21 +126,17 @@ static void InitTrack(MessageField* aMsg
sTitle? NS_ConvertUTF8toUTF16(*sTitle):EmptyString(),
sLanguage? NS_ConvertUTF8toUTF16(*sLanguage):EmptyString(),
aEnable);
}
OggReader::OggReader(AbstractMediaDecoder* aDecoder)
: MediaDecoderReader(aDecoder),
mMonitor("OggReader"),
- mTheoraState(nullptr),
- mVorbisState(nullptr),
- mOpusState(nullptr),
mOpusEnabled(MediaDecoder::IsOpusEnabled()),
- mSkeletonState(nullptr),
mVorbisSerial(0),
mOpusSerial(0),
mTheoraSerial(0),
mOpusPreSkip(0),
mIsChained(false),
mDecodedAudioFrames(0),
mResource(aDecoder->GetResource())
{
--- a/dom/media/ogg/OggReader.h
+++ b/dom/media/ogg/OggReader.h
@@ -250,31 +250,31 @@ private:
void SetupTargetVorbis(VorbisState* aVorbisState);
void SetupTargetOpus(OpusState* aOpusState);
void SetupTargetSkeleton(SkeletonState* aSkeletonState);
void SetupMediaTracksInfo(const nsTArray<uint32_t>& aSerials);
OggCodecStore mCodecStore;
// Decode state of the Theora bitstream we're decoding, if we have video.
- TheoraState* mTheoraState;
+ nsAutoPtr<TheoraState> mTheoraState;
// Decode state of the Vorbis bitstream we're decoding, if we have audio.
- VorbisState* mVorbisState;
+ nsAutoPtr<VorbisState> mVorbisState;
// Decode state of the Opus bitstream we're decoding, if we have one.
- OpusState *mOpusState;
+ nsAutoPtr<OpusState> mOpusState;
// Represents the user pref media.opus.enabled at the time our
// contructor was called. We can't check it dynamically because
// we're not on the main thread;
bool mOpusEnabled;
// Decode state of the Skeleton bitstream.
- SkeletonState* mSkeletonState;
+ nsAutoPtr<SkeletonState> mSkeletonState;
// Ogg decoding state.
ogg_sync_state mOggState;
// Vorbis/Opus/Theora data used to compute timestamps. This is written on the
// decoder thread and read on the main thread. All reading on the main
// thread must be done after metadataloaded. We can't use the existing
// data in the codec states due to threading issues. You must check the