Skip to content

Commit

Permalink
Merge pull request #816 from CastagnaIT/fix_crash_no_data
Browse files Browse the repository at this point in the history
Fixed missing no-data check on DemuxRead
  • Loading branch information
glennguy authored Oct 8, 2021
2 parents d794c58 + 3c49284 commit 22b77be
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3857,7 +3857,7 @@ DEMUX_PACKET* CInputStreamAdaptive::DemuxRead(void)
const AP4_UI08* pData(sr->GetSampleData());
DEMUX_PACKET* p;

if (iSize && pData && sr->IsEncrypted())
if (sr->IsEncrypted() && iSize > 0 && pData)
{
unsigned int numSubSamples(*((unsigned int*)pData));
pData += sizeof(numSubSamples);
Expand All @@ -3876,13 +3876,16 @@ DEMUX_PACKET* CInputStreamAdaptive::DemuxRead(void)
else
p = AllocateDemuxPacket(iSize);

p->dts = static_cast<double>(sr->DTS() + m_session->GetChapterStartTime());
p->pts = static_cast<double>(sr->PTS() + m_session->GetChapterStartTime());
p->duration = static_cast<double>(sr->GetDuration());
p->iStreamId = sr->GetStreamId();
p->iGroupId = 0;
p->iSize = iSize;
memcpy(p->pData, pData, iSize);
if (iSize > 0 && pData)
{
p->dts = static_cast<double>(sr->DTS() + m_session->GetChapterStartTime());
p->pts = static_cast<double>(sr->PTS() + m_session->GetChapterStartTime());
p->duration = static_cast<double>(sr->GetDuration());
p->iStreamId = sr->GetStreamId();
p->iGroupId = 0;
p->iSize = iSize;
memcpy(p->pData, pData, iSize);
}

//kodi::Log(ADDON_LOG_DEBUG, "DTS: %0.4f, PTS:%0.4f, ID: %u SZ: %d", p->dts, p->pts, p->iStreamId, p->iSize);

Expand Down

0 comments on commit 22b77be

Please sign in to comment.