container/mts: checking index so that we don't go out of bounds

This commit is contained in:
Saxon 2019-07-01 13:54:18 +09:30
parent 0497ee5302
commit 0d240fa7ff
1 changed files with 3 additions and 0 deletions

View File

@ -324,6 +324,9 @@ func GetPTSRange(clip []byte, pid uint16) (pts [2]uint64, err error) {
// Find the first packet with PID pidType and PUSI. // Find the first packet with PID pidType and PUSI.
var i int var i int
for { for {
if i >= len(clip) {
return [2]uint64{}, errors.New("could not find payload start")
}
pkt, _i, err := FindPid(clip[i:], pid) pkt, _i, err := FindPid(clip[i:], pid)
if err != nil { if err != nil {
return [2]uint64{}, err return [2]uint64{}, err