codec/mjpeg/lex.go: return error if io.EOF is encountered

This commit is contained in:
Saxon 2020-01-17 16:07:37 +10:30
parent a26777b697
commit e45f51a31f
1 changed files with 2 additions and 8 deletions

View File

@ -63,10 +63,7 @@ func Lex(dst io.Writer, src io.Reader, delay time.Duration) error {
return nil
}
if err != nil {
if err == io.EOF {
return nil
}
return err
return fmt.Errorf("can't read source: %w", err)
}
if !bytes.Equal(buf, []byte{0xff, 0xd8}) {
return fmt.Errorf("parser: not MJPEG frame start: %#v", buf)
@ -75,10 +72,7 @@ func Lex(dst io.Writer, src io.Reader, delay time.Duration) error {
for {
b, err := r.ReadByte()
if err != nil {
if err == io.EOF {
return nil
}
return err
return fmt.Errorf("can't read byte: %w", err)
}
buf = append(buf, b)
if last == 0xff && b == 0xd9 {