Fix crash when seeing unsupported es descriptor data

Addresses #175

Change-Id: Ia9c2f0c7a8c17a6614db0fe478892bd3c5efd5b0
This commit is contained in:
Kongqun Yang 2016-11-29 15:24:09 -08:00 committed by KongQun Yang
parent 9ed8303a06
commit eab7910029
2 changed files with 6 additions and 7 deletions

View File

@ -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<FourCC, BoxReader*>(box_type, child.release()));
children_.insert(std::pair<FourCC, std::unique_ptr<BoxReader>>(
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;
}

View File

@ -6,6 +6,7 @@
#define MEDIA_FORMATS_MP4_BOX_READER_H_
#include <map>
#include <memory>
#include <vector>
#include "packager/base/compiler_specific.h"
@ -112,7 +113,7 @@ class BoxReader : public BufferReader {
FourCC type_;
typedef std::multimap<FourCC, BoxReader*> ChildMap;
typedef std::multimap<FourCC, std::unique_ptr<BoxReader>> 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<T>* children) {
children->resize(std::distance(start_itr, end_itr));
typename std::vector<T>::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);