diff --git a/packager/media/formats/mp4/box_reader.cc b/packager/media/formats/mp4/box_reader.cc index a803e84c3c..b673e7304f 100644 --- a/packager/media/formats/mp4/box_reader.cc +++ b/packager/media/formats/mp4/box_reader.cc @@ -28,7 +28,6 @@ BoxReader::~BoxReader() { for (ChildMap::iterator itr = children_.begin(); itr != children_.end(); ++itr) { DVLOG(1) << "Skipping unknown box: " << FourCCToString(itr->first); - delete itr->second; } } } @@ -78,7 +77,8 @@ bool BoxReader::ScanChildren() { FourCC box_type = child->type(); size_t box_size = child->size(); - children_.insert(std::pair(box_type, child.release())); + children_.insert(std::pair>( + box_type, std::move(child))); RCHECK(SkipBytes(box_size)); } @@ -92,8 +92,7 @@ bool BoxReader::ReadChild(Box* child) { ChildMap::iterator itr = children_.find(child_type); RCHECK(itr != children_.end()); DVLOG(2) << "Found a " << FourCCToString(child_type) << " box."; - RCHECK(child->Parse(itr->second)); - delete itr->second; + RCHECK(child->Parse(itr->second.get())); children_.erase(itr); return true; } diff --git a/packager/media/formats/mp4/box_reader.h b/packager/media/formats/mp4/box_reader.h index 18fda7008c..4df0b1b34c 100644 --- a/packager/media/formats/mp4/box_reader.h +++ b/packager/media/formats/mp4/box_reader.h @@ -6,6 +6,7 @@ #define MEDIA_FORMATS_MP4_BOX_READER_H_ #include +#include #include #include "packager/base/compiler_specific.h" @@ -112,7 +113,7 @@ class BoxReader : public BufferReader { FourCC type_; - typedef std::multimap ChildMap; + typedef std::multimap> ChildMap; // The set of child box FourCCs and their corresponding buffer readers. Only // valid if scanned_ is true. @@ -142,8 +143,7 @@ bool BoxReader::TryReadChildren(std::vector* children) { children->resize(std::distance(start_itr, end_itr)); typename std::vector::iterator child_itr = children->begin(); for (ChildMap::iterator itr = start_itr; itr != end_itr; ++itr) { - RCHECK(child_itr->Parse(itr->second)); - delete itr->second; + RCHECK(child_itr->Parse(itr->second.get())); ++child_itr; } children_.erase(start_itr, end_itr);