audio/wav: Bug fix: return an error when offset is before the start of the data

This commit is contained in:
Hajime Hoshi 2016-09-27 02:13:56 +09:00
parent a14b4c8046
commit 2eac8dca8c

View File

@ -50,8 +50,14 @@ func (s *Stream) Seek(offset int64, whence int) (int64, error) {
offset += s.headerSize
}
n, err := s.src.Seek(offset, whence)
if err != nil {
return 0, err
}
if n-s.headerSize < 0 {
return 0, fmt.Errorf("wav: invalid offset")
}
s.remaining = s.dataSize - (n - s.headerSize)
return n, err
return n, nil
}
// Read is implementation of io.Closer's Close.