mirror of https://github.com/fafhrd91/actix-web
set length of vector to max_bytes (closes #345)
This commit is contained in:
parent
800c404c72
commit
0b4954ed79
|
@ -440,6 +440,8 @@ impl Stream for ChunkedReadFile {
|
|||
let max_bytes: usize;
|
||||
max_bytes = cmp::min(size.saturating_sub(counter), 65_536) as usize;
|
||||
let mut buf = Vec::with_capacity(max_bytes);
|
||||
// safe because memory is initialized/overwritten immediately
|
||||
unsafe { buf.set_len(max_bytes); }
|
||||
file.seek(io::SeekFrom::Start(offset))?;
|
||||
let nbytes = file.read(buf.as_mut_slice())?;
|
||||
if nbytes == 0 {
|
||||
|
|
Loading…
Reference in New Issue