Skip to content

Commit

Permalink
fix #975
Browse files Browse the repository at this point in the history
  • Loading branch information
barbibulle committed Aug 4, 2024
1 parent 874c264 commit 324c571
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions Source/C++/Core/Ap4TrunAtom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
+---------------------------------------------------------------------*/
AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_TrunAtom)

/*----------------------------------------------------------------------
| constants
+---------------------------------------------------------------------*/
#define AP4_TRUN_MAX_SAMPLE_COUNT 0xFFFFFF

/*----------------------------------------------------------------------
| AP4_TrunAtom::Create
+---------------------------------------------------------------------*/
Expand Down Expand Up @@ -143,14 +148,15 @@ AP4_TrunAtom::AP4_TrunAtom(AP4_UI32 size,
}

int record_fields_count = (int)ComputeRecordFieldsCount(flags);
if (!record_fields_count) {
// nothing to read
return;
}

if ((bytes_left / (record_fields_count*4)) < sample_count) {
// not enough data for all samples, the format is invalid
return;
if (record_fields_count) {
if ((bytes_left / (record_fields_count*4)) < sample_count) {
// not enough data for all samples, the format is invalid
return;
}
} else {
if (sample_count > AP4_TRUN_MAX_SAMPLE_COUNT) {
return;
}
}

if (AP4_FAILED(m_Entries.SetItemCount(sample_count))) {
Expand Down

0 comments on commit 324c571

Please sign in to comment.