codec/mjpeg/lex.go: returning nil error from Lex if we get io.EOF on reading bytes

This commit is contained in:
Saxon 2019-10-03 00:32:34 +09:30
parent 8df837ee49
commit 1c9146eec0
1 changed files with 8 additions and 2 deletions

View File

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