Skip to content

Commit

Permalink
fix #517
Browse files Browse the repository at this point in the history
  • Loading branch information
barbibulle committed Jun 12, 2020
1 parent 99d7d8c commit e6c7cda
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions Source/C++/Core/Ap4StszAtom.cpp
Expand Up @@ -78,25 +78,23 @@ AP4_StszAtom::AP4_StszAtom(AP4_UI32 size,
}

stream.ReadUI32(m_SampleSize);
AP4_UI32 sample_count;
stream.ReadUI32(sample_count);
stream.ReadUI32(m_SampleCount);
if (m_SampleSize == 0) { // means that the samples have different sizes
// check for overflow
if (m_SampleCount > (size - AP4_FULL_ATOM_HEADER_SIZE - 8) / 4) {
return;
}

// read the entries
unsigned char* buffer = new unsigned char[sample_count * 4];
AP4_Result result = stream.Read(buffer, sample_count*4);
unsigned char* buffer = new unsigned char[m_SampleCount * 4];
AP4_Result result = stream.Read(buffer, m_SampleCount * 4);
if (AP4_FAILED(result)) {
delete[] buffer;
return;
}
m_SampleCount = sample_count;
m_Entries.SetItemCount((AP4_Cardinal)sample_count);
for (unsigned int i=0; i<sample_count; i++) {
m_Entries[i] = AP4_BytesToUInt32BE(&buffer[i*4]);
m_Entries.SetItemCount((AP4_Cardinal)m_SampleCount);
for (unsigned int i = 0; i < m_SampleCount; i++) {
m_Entries[i] = AP4_BytesToUInt32BE(&buffer[i * 4]);
}
delete[] buffer;
}
Expand Down

0 comments on commit e6c7cda

Please sign in to comment.