Fix ParseElementHeader to support 0 payload elements

Cherry-pick'ing Change 5c83bbec9a5f6f00a349674ddad85b753d2ea219
from upstream. This fixes regression in some edge cases for mkv
playback.

BUG=26499283

Change-Id: I88de03219a3d941b6b2f251d384e29c36bdd4d9b

bool Cues::Init() const {
 if (m_cue_points)
 return true;

 if (m_count != 0 || m_preload_count != 0)
 return false;

 IMkvReader* const pReader = m_pSegment->m_pReader;

 const long long stop = m_start + m_size;
 long long pos = m_start;

 long cue_points_size = 0;

 while (pos < stop) {
 const long long idpos = pos;

 long len;

 const long long id = ReadID(pReader, pos, len);
 if (id < 0 || (pos + len) > stop) {
 return false;
 }

    pos += len; // consume ID

 const long long size = ReadUInt(pReader, pos, len);
 if (size < 0 || (pos + len > stop)) {
 return false;
 }

    pos += len; // consume Size field
 if (pos + size > stop) {
 return false;
 }

 if (id == 0x3B) { // CuePoint ID
 if (!PreloadCuePoint(cue_points_size, idpos))
 return false;
 }

    pos += size; // skip payload
 }
 return true;
}

bool Cues::Init() const {
 if (m_cue_points)
 return true;

 if (m_count != 0 || m_preload_count != 0)
 return false;

 IMkvReader* const pReader = m_pSegment->m_pReader;

 const long long stop = m_start + m_size;
 long long pos = m_start;

 long cue_points_size = 0;

 while (pos < stop) {
 const long long idpos = pos;

 long len;

 const long long id = ReadID(pReader, pos, len);
 if (id < 0 || (pos + len) > stop) {
 return false;
 }

    pos += len; // consume ID

 const long long size = ReadUInt(pReader, pos, len);
 if (size < 0 || (pos + len > stop)) {
 return false;
 }

    pos += len; // consume Size field
 if (pos + size > stop) {
 return false;
 }

 if (id == 0x3B) { // CuePoint ID
 if (!PreloadCuePoint(cue_points_size, idpos))
 return false;
 }

    pos += size; // skip payload
 }
 return true;
}
