Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](BufferedReader) fix BufferedReader::_read_once call memcpy function using null pointor _buffer #27775

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions be/src/io/buffered_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,15 @@ Status BufferedReader::_read_once(int64_t position, int64_t nbytes, int64_t* byt
return Status::OK();
}
}

int64_t len = std::min(_buffer_limit - position, nbytes);
int64_t off = position - _buffer_offset;
if (_buffer == nullptr || out == nullptr || off + len > _buffer_size) {
return Status::BufferAllocFailed(
"BufferedReader copy argument invaild: _buffer:{},\
out:{},_buffer_size:{},off:{},len:{}",
_buffer, out, _buffer_size, off, len);
}
memcpy(out, _buffer + off, len);
*bytes_read = len;
_cur_offset = position + *bytes_read;
Expand Down