Skip to content

Commit 5d823ba

Browse files
lx200916lx200916
and
lx200916
authored
fix: prevent panic in FileReader when buffer size exceeds file length. (#210)
* fix: prevent panic in FileReader when buffer size exceeds file length. --------- Co-authored-by: lx200916 <zekli@tencent.com>
1 parent 6e726c3 commit 5d823ba

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

rust/src/file.rs

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ impl FileReader {
8888
let offset = self.position;
8989
self.position = usize::min(self.position + buf.len(), self.file_length());
9090
let read_bytes = self.position - offset;
91+
let buf = &mut buf[..read_bytes];
9192
self.read_range_buf(buf, offset).await?;
9293
Ok(read_bytes)
9394
}

0 commit comments

Comments
 (0)