[Bug] Fix bug that the buffered reader may read at wrong position. (#5847)

The buffered reader's _cur_offset should be initialized as same as the inner file reader's,
to make sure that the reader will start to read at rignt position.
This commit is contained in:
Mingyu Chen
2021-05-22 23:38:10 +08:00
committed by GitHub
parent 07ad038870
commit 591d391bbc
2 changed files with 10 additions and 0 deletions

View File

@ -32,6 +32,9 @@ BufferedReader::BufferedReader(FileReader* reader, int64_t buffer_size)
_buffer_limit(0),
_cur_offset(0) {
_buffer = new char[_buffer_size];
// set the _cur_offset of this reader as same as the inner reader's,
// to make sure the buffer reader will start to read at right position.
_reader->tell(&_cur_offset);
}
BufferedReader::~BufferedReader() {