-
Notifications
You must be signed in to change notification settings - Fork 13.3k
fix soundness issue in make_contiguous
#79814
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,6 +210,20 @@ fn make_contiguous_small_free() { | |
); | ||
} | ||
|
||
#[test] | ||
fn make_contiguous_head_to_end() { | ||
let mut dq = VecDeque::with_capacity(3); | ||
dq.push_front('B'); | ||
dq.push_front('A'); | ||
dq.push_back('C'); | ||
dq.make_contiguous(); | ||
let expected_tail = 0; | ||
let expected_head = 3; | ||
assert_eq!(expected_tail, dq.tail); | ||
assert_eq!(expected_head, dq.head); | ||
assert_eq!((&['A', 'B', 'C'] as &[_], &[] as &[_]), dq.as_slices()); | ||
} | ||
Comment on lines
+213
to
+225
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want to write a version of this that uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that shouldn't matter i think. The reason this could segfault is if the result is wrong. But as the used algorithm doesn't depend on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably, but I figured better safe than sorry :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, don't have the capacity for this rn though. |
||
|
||
#[test] | ||
fn test_remove() { | ||
// This test checks that every single combination of tail position, length, and | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was only a perfomance issue because
is_contiguous
returns false if thehead
is 0