mkvparser: Cues::PreloadCuePoint now returns bool.

Check allocations and fail appropriately.

Change-Id: Ie16d258a47e46b5e15c5c6275ea83ebead8b0f49
This commit is contained in:
Tom Finegan 2015-08-24 14:55:27 -07:00
parent 064f2eed62
commit 1a6dc4f210
2 changed files with 15 additions and 6 deletions

View File

@ -1838,21 +1838,26 @@ bool Cues::Init() const {
return false;
}
if (id == 0x3B) // CuePoint ID
PreloadCuePoint(cue_points_size, idpos);
if (id == 0x3B) { // CuePoint ID
if (!PreloadCuePoint(cue_points_size, idpos))
return false;
}
pos += size; // skip payload
}
return true;
}
void Cues::PreloadCuePoint(long& cue_points_size, long long pos) const {
bool Cues::PreloadCuePoint(long& cue_points_size, long long pos) const {
assert(m_count == 0);
if (m_preload_count >= cue_points_size) {
const long n = (cue_points_size <= 0) ? 2048 : 2 * cue_points_size;
CuePoint** const qq = new CuePoint*[n];
CuePoint** const qq = new (std::nothrow) CuePoint*[n];
if (qq == NULL)
return false;
CuePoint** q = qq; // beginning of target
CuePoint** p = m_cue_points; // beginning of source
@ -1867,8 +1872,12 @@ void Cues::PreloadCuePoint(long& cue_points_size, long long pos) const {
cue_points_size = n;
}
CuePoint* const pCP = new CuePoint(m_preload_count, pos);
CuePoint* const pCP = new (std::nothrow) CuePoint(m_preload_count, pos);
if (pCP == NULL)
return false;
m_cue_points[m_preload_count++] = pCP;
return true;
}
bool Cues::LoadCuePoint() const {

View File

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