Skip to content

Commit

Permalink
Ensure reverse_part does not access outside given vector
Browse files Browse the repository at this point in the history
  • Loading branch information
tmmcguire authored and emberian committed May 17, 2013
1 parent 2264c79 commit 5948d8a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/libcore/vec.rs
Expand Up @@ -1450,6 +1450,9 @@ pub fn reverse<T>(v: &mut [T]) {
*
* Reverse the elements in the vector between `start` and `end - 1`.
*
* If either start or end do not represent valid positions in the vector, the
* vector is returned unchanged.
*
* # Arguments
*
* * `v` - The mutable vector to be modified
Expand All @@ -1469,13 +1472,10 @@ pub fn reverse<T>(v: &mut [T]) {
* ~~~
*
* `v` now contains `[1,4,3,2,5]`.
*
* # Safety note
*
* Behavior is undefined if `start` or `end` do not represent valid
* positions in `v`.
*/
pub fn reverse_part<T>(v: &mut [T], start: uint, end : uint) {
let sz = v.len();
if start >= sz || end > sz { return; }
let mut i = start;
let mut j = end - 1;
while i < j {
Expand Down

0 comments on commit 5948d8a

Please sign in to comment.