Change assertions to checks when preloading Cues

If a malformed webm file contains invalid information on the Cues
the segment, the parser would assert.

Instead, now it ignores the Cues and skips the segment.

Change-Id: I9270f6a0935ce9e9a3765a5f324ae542c1ade1c7
This commit is contained in:
Leonel Togniolli
2015-04-11 01:36:41 +01:00
parent d3a44cd549
commit f439e523b8
2 changed files with 18 additions and 11 deletions

View File

@@ -2152,9 +2152,9 @@ bool Cues::DoneParsing() const {
return (m_pos >= stop); return (m_pos >= stop);
} }
void Cues::Init() const { bool Cues::Init() const {
if (m_cue_points) if (m_cue_points)
return; return true;
assert(m_count == 0); assert(m_count == 0);
assert(m_preload_count == 0); assert(m_preload_count == 0);
@@ -2172,24 +2172,28 @@ void Cues::Init() const {
long len; long len;
const long long id = ReadUInt(pReader, pos, len); const long long id = ReadUInt(pReader, pos, len);
assert(id >= 0); // TODO if (id < 0 || (pos + len) > stop) {
assert((pos + len) <= stop); return false;
}
pos += len; // consume ID pos += len; // consume ID
const long long size = ReadUInt(pReader, pos, len); const long long size = ReadUInt(pReader, pos, len);
assert(size >= 0); if (size < 0 || (pos + len > stop)) {
assert((pos + len) <= stop); return false;
}
pos += len; // consume Size field pos += len; // consume Size field
assert((pos + size) <= stop); if (pos + size > stop) {
return false;
}
if (id == 0x3B) // CuePoint ID if (id == 0x3B) // CuePoint ID
PreloadCuePoint(cue_points_size, idpos); PreloadCuePoint(cue_points_size, idpos);
pos += size; // consume payload pos += size; // skip payload
assert(pos <= stop);
} }
return true;
} }
void Cues::PreloadCuePoint(long& cue_points_size, long long pos) const { void Cues::PreloadCuePoint(long& cue_points_size, long long pos) const {
@@ -2226,7 +2230,10 @@ bool Cues::LoadCuePoint() const {
if (m_pos >= stop) if (m_pos >= stop)
return false; // nothing else to do return false; // nothing else to do
Init(); if (!Init()) {
m_pos = stop;
return false;
}
IMkvReader* const pReader = m_pSegment->m_pReader; IMkvReader* const pReader = m_pSegment->m_pReader;

View File

@@ -758,7 +758,7 @@ class Cues {
bool DoneParsing() const; bool DoneParsing() const;
private: private:
void Init() const; bool Init() const;
void PreloadCuePoint(long&, long long) const; void PreloadCuePoint(long&, long long) const;
mutable CuePoint** m_cue_points; mutable CuePoint** m_cue_points;