mkvparser: Segment::PreloadCluster asserts to error checks.
Change-Id: I3a2e2226f30ee047f96f5136c52e4cb9081d42c8
This commit is contained in:
@@ -1336,14 +1336,14 @@ bool Segment::AppendCluster(Cluster* pCluster) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Segment::PreloadCluster(Cluster* pCluster, ptrdiff_t idx) {
|
bool Segment::PreloadCluster(Cluster* pCluster, ptrdiff_t idx) {
|
||||||
assert(pCluster);
|
if (pCluster == NULL || pCluster->m_index >= 0 || idx < m_clusterCount)
|
||||||
assert(pCluster->m_index < 0);
|
return false;
|
||||||
assert(idx >= m_clusterCount);
|
|
||||||
|
|
||||||
const long count = m_clusterCount + m_clusterPreloadCount;
|
const long count = m_clusterCount + m_clusterPreloadCount;
|
||||||
|
|
||||||
long& size = m_clusterSize;
|
long& size = m_clusterSize;
|
||||||
assert(size >= count);
|
if (size < count)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (count >= size) {
|
if (count >= size) {
|
||||||
const long n = (size <= 0) ? 2048 : 2 * size;
|
const long n = (size <= 0) ? 2048 : 2 * size;
|
||||||
@@ -1365,17 +1365,20 @@ bool Segment::PreloadCluster(Cluster* pCluster, ptrdiff_t idx) {
|
|||||||
size = n;
|
size = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(m_clusters);
|
if (m_clusters == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
Cluster** const p = m_clusters + idx;
|
Cluster** const p = m_clusters + idx;
|
||||||
|
|
||||||
Cluster** q = m_clusters + count;
|
Cluster** q = m_clusters + count;
|
||||||
assert(q >= p);
|
if (q < p || q >= (m_clusters + size))
|
||||||
assert(q < (m_clusters + size));
|
return false;
|
||||||
|
|
||||||
while (q > p) {
|
while (q > p) {
|
||||||
Cluster** const qq = q - 1;
|
Cluster** const qq = q - 1;
|
||||||
assert((*qq)->m_index < 0);
|
|
||||||
|
if ((*qq)->m_index >= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
*q = *qq;
|
*q = *qq;
|
||||||
q = qq;
|
q = qq;
|
||||||
|
|||||||
Reference in New Issue
Block a user