Skip to content
Snippets Groups Projects
Unverified Commit ebe52273 authored by Carl Lerche's avatar Carl Lerche
Browse files

Fix `copy_to_slice` to use correct increment var

This patch fixes the `copy_to_slice` function, rectifying the logic.
However, the incorrect code does not result in incorrect behavior as the
only case `cnt != src.len()` is during the final iteration, and since
`src.len()` is greater than `cnt` in that case, `off` will be
incremented by too much, but this will still trigger the `off <
dst.len()` condition.

The only danger is `src.len()` could cause an overflow.
parent bd4630a3
No related branches found
No related tags found
No related merge requests found
...@@ -218,7 +218,7 @@ pub trait Buf { ...@@ -218,7 +218,7 @@ pub trait Buf {
ptr::copy_nonoverlapping( ptr::copy_nonoverlapping(
src.as_ptr(), dst[off..].as_mut_ptr(), cnt); src.as_ptr(), dst[off..].as_mut_ptr(), cnt);
off += src.len(); off += cnt;
} }
self.advance(cnt); self.advance(cnt);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment