Code: long Tracks::Parse()
{
    assert(m_trackEntries == NULL);
    assert(m_trackEntriesEnd == NULL);
    const long long stop = m_start + m_size;
    IMkvReader* const pReader = m_pSegment->m_pReader;
    int count = 0;
    long long pos = m_start;
    while (pos < stop)
    {
        long long id, size;
        const long status = ParseElementHeader(
                                pReader,
                                pos,
                                stop,
                                id,
                                size);
        if (status < 0)  //error
            return status;
        if (size == 0)  //weird
            continue;
        if (id == 0x2E)  //TrackEntry ID
            ++count;
        pos += size;  //consume payload
        assert(pos <= stop);
    }
    assert(pos == stop);
    if (count <= 0)
        return 0;  //success
    m_trackEntries = new (std::nothrow) Track*[count];
    if (m_trackEntries == NULL)
        return -1;
    m_trackEntriesEnd = m_trackEntries;
    pos = m_start;
    while (pos < stop)
    {
        const long long element_start = pos;
        long long id, payload_size;
        const long status = ParseElementHeader(
                                pReader,
                                pos,
                                stop,
                                id,
                                payload_size);
        if (status < 0)  //error
            return status;
        if (payload_size == 0)  //weird
            continue;
        const long long payload_stop = pos + payload_size;
        assert(payload_stop <= stop);  //checked in ParseElement
        const long long element_size = payload_stop - element_start;
        if (id == 0x2E)  //TrackEntry ID
        {
            Track*& pTrack = *m_trackEntriesEnd;
            pTrack = NULL;
            const long status = ParseTrackEntry(
                                    pos,
                                    payload_size,
                                    element_start,
                                    element_size,
                                    pTrack);
            if (status)
                return status;
            if (pTrack)
                ++m_trackEntriesEnd;
        }
        pos = payload_stop;
        assert(pos <= stop);
    }
    assert(pos == stop);
    return 0;  //success
}

Vulnerability Type: DoS Exec Code Overflow Mem. Corr. 
CWE ID: CWE-119
Summary: libvpx in mediaserver in Android 4.x before 4.4.4, 5.x before 5.1.1 LMY49H, and 6.0 before 2016-03-01 allows remote attackers to execute arbitrary code or cause a denial of service (memory corruption) via a crafted media file, related to libwebm/mkvparser.cpp and other files, aka internal bug 23452792.
Commit Message: libwebm: Pull from upstream

Rolling mkvparser from upstream. Primarily for fixing a bug on parsing
failures with certain Opus WebM files.

Upstream commit hash of this pull: 574045edd4ecbeb802ee3f1d214b5510269852ae

The diff is so huge because there were some style clean ups upstream.
But it was ensured that there were no breaking changes when the style
clean ups was done upstream.

Change-Id: Ib6e907175484b4b0ae1b55ab39522ea3188ad039