From 335f9a95b62296c19e8c459fa8fdb26eda6ea94e Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Thu, 9 Feb 2017 23:09:00 +0000 Subject: [PATCH] Fix demuxer long hang on invalid video stream data --- demuxer.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/demuxer.cc b/demuxer.cc index 50343cb..a38b0de 100644 --- a/demuxer.cc +++ b/demuxer.cc @@ -156,7 +156,7 @@ UINT NALUUnit::getUe() bool bit; for( bit = 0; !bit && !eonalu; leadbits++ ) bit = getBits(1); - if (eonalu) return true; + if (eonalu) return 0; return ((1 << leadbits)-1)+getBits(leadbits); } @@ -383,7 +383,17 @@ UINT PESPacket::countPictureHeaders(bool h264, struct PictCountInfo& pinfo) cons } } - pinfo.log2_max_frame_num=nalu.getUe()+4; //log2framenum + UINT checkMaxFrameNum = nalu.getUe() + 4; //log2framenum + + if (checkMaxFrameNum < 13) { + pinfo.log2_max_frame_num = checkMaxFrameNum; + } + else { + pattern=0xFFFFFF; + pos+=nalu.getPos(); + continue; + } + UINT temp=nalu.getUe(); if (temp==0) //pict order nalu.getUe(); -- 2.39.5