codec/h264/lex.go: fixed handling of errors from ScanUntil

This commit is contained in:
Saxon 2020-01-22 13:43:08 +10:30
parent bf289221de
commit 78484b5f5b
1 changed files with 7 additions and 1 deletions

View File

@ -72,8 +72,14 @@ func Lex(dst io.Writer, src io.Reader, delay time.Duration) error {
var err error
buf, b, err = c.ScanUntil(buf, 0x00)
if err != nil {
if err != io.EOF {
return err
}
if len(buf) != 0 {
return io.ErrUnexpectedEOF
}
return io.EOF
}
for n := 1; b == 0x0 && n < 4; n++ {
b, err = c.ReadByte()