diff --git a/Source/C++/Core/Ap4HdlrAtom.cpp b/Source/C++/Core/Ap4HdlrAtom.cpp index 42c117c54..e784ce668 100644 --- a/Source/C++/Core/Ap4HdlrAtom.cpp +++ b/Source/C++/Core/Ap4HdlrAtom.cpp @@ -89,7 +89,7 @@ AP4_HdlrAtom::AP4_HdlrAtom(AP4_UI32 size, // handle a special case: the Quicktime files have a pascal // string here, but ISO MP4 files have a C string. // we try to detect a pascal encoding and correct it. - if (name[0] == name_size-1) { + if ((AP4_UI08)name[0] == (AP4_UI08)(name_size-1)) { m_HandlerName = name+1; } else { m_HandlerName = name; diff --git a/Source/C++/Core/Ap4StszAtom.cpp b/Source/C++/Core/Ap4StszAtom.cpp index 2af9fecfe..cc4577a14 100644 --- a/Source/C++/Core/Ap4StszAtom.cpp +++ b/Source/C++/Core/Ap4StszAtom.cpp @@ -73,6 +73,13 @@ AP4_StszAtom::AP4_StszAtom(AP4_UI32 size, stream.ReadUI32(m_SampleSize); stream.ReadUI32(m_SampleCount); if (m_SampleSize == 0) { // means that the samples have different sizes + // check for overflow + if (m_SampleCount > (size-8)/4) { + m_SampleCount = 0; + return; + } + + // read the entries AP4_Cardinal sample_count = m_SampleCount; m_Entries.SetItemCount(sample_count); unsigned char* buffer = new unsigned char[sample_count*4];