Fix crash when seeing unsupported es descriptor data
Addresses #175 Change-Id: Ia9c2f0c7a8c17a6614db0fe478892bd3c5efd5b0
This commit is contained in:
parent
9ed8303a06
commit
eab7910029
|
@ -28,7 +28,6 @@ BoxReader::~BoxReader() {
|
||||||
for (ChildMap::iterator itr = children_.begin(); itr != children_.end();
|
for (ChildMap::iterator itr = children_.begin(); itr != children_.end();
|
||||||
++itr) {
|
++itr) {
|
||||||
DVLOG(1) << "Skipping unknown box: " << FourCCToString(itr->first);
|
DVLOG(1) << "Skipping unknown box: " << FourCCToString(itr->first);
|
||||||
delete itr->second;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +77,8 @@ bool BoxReader::ScanChildren() {
|
||||||
|
|
||||||
FourCC box_type = child->type();
|
FourCC box_type = child->type();
|
||||||
size_t box_size = child->size();
|
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));
|
RCHECK(SkipBytes(box_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,8 +92,7 @@ bool BoxReader::ReadChild(Box* child) {
|
||||||
ChildMap::iterator itr = children_.find(child_type);
|
ChildMap::iterator itr = children_.find(child_type);
|
||||||
RCHECK(itr != children_.end());
|
RCHECK(itr != children_.end());
|
||||||
DVLOG(2) << "Found a " << FourCCToString(child_type) << " box.";
|
DVLOG(2) << "Found a " << FourCCToString(child_type) << " box.";
|
||||||
RCHECK(child->Parse(itr->second));
|
RCHECK(child->Parse(itr->second.get()));
|
||||||
delete itr->second;
|
|
||||||
children_.erase(itr);
|
children_.erase(itr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#define MEDIA_FORMATS_MP4_BOX_READER_H_
|
#define MEDIA_FORMATS_MP4_BOX_READER_H_
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "packager/base/compiler_specific.h"
|
#include "packager/base/compiler_specific.h"
|
||||||
|
@ -112,7 +113,7 @@ class BoxReader : public BufferReader {
|
||||||
|
|
||||||
FourCC type_;
|
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
|
// The set of child box FourCCs and their corresponding buffer readers. Only
|
||||||
// valid if scanned_ is true.
|
// valid if scanned_ is true.
|
||||||
|
@ -142,8 +143,7 @@ bool BoxReader::TryReadChildren(std::vector<T>* children) {
|
||||||
children->resize(std::distance(start_itr, end_itr));
|
children->resize(std::distance(start_itr, end_itr));
|
||||||
typename std::vector<T>::iterator child_itr = children->begin();
|
typename std::vector<T>::iterator child_itr = children->begin();
|
||||||
for (ChildMap::iterator itr = start_itr; itr != end_itr; ++itr) {
|
for (ChildMap::iterator itr = start_itr; itr != end_itr; ++itr) {
|
||||||
RCHECK(child_itr->Parse(itr->second));
|
RCHECK(child_itr->Parse(itr->second.get()));
|
||||||
delete itr->second;
|
|
||||||
++child_itr;
|
++child_itr;
|
||||||
}
|
}
|
||||||
children_.erase(start_itr, end_itr);
|
children_.erase(start_itr, end_itr);
|
||||||
|
|
Loading…
Reference in New Issue