-
Notifications
You must be signed in to change notification settings - Fork 5
/
0150-stack_dst.rs
46 lines (37 loc) · 1.03 KB
/
0150-stack_dst.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*!
```rudra-poc
[target]
crate = "stack_dst"
version = "0.6.0"
[report]
issue_url = "https://github.com/thepowersgang/stack_dst-rs/issues/5"
issue_date = 2021-02-22
rustsec_url = "https://github.com/RustSec/advisory-db/pull/799"
rustsec_id = "RUSTSEC-2021-0033"
[[bugs]]
analyzer = "UnsafeDataflow"
bug_class = "PanicSafety"
rudra_report_locations = ["src/stack.rs:184:2: 202:3"]
```
!*/
#![forbid(unsafe_code)]
use stack_dst::StackA;
#[derive(Debug)]
struct DropDetector(u32);
impl Drop for DropDetector {
fn drop(&mut self) {
println!("Dropping {}", self.0);
}
}
impl Clone for DropDetector {
fn clone(&self) -> Self { panic!("Panic in clone()") }
}
fn main() {
let mut stack = StackA::<[DropDetector], [usize; 9]>::new();
stack.push_stable([DropDetector(1)], |p| p).unwrap();
stack.push_stable([DropDetector(2)], |p| p).unwrap();
println!("Popping off second drop detector");
let second_drop = stack.pop();
println!("Pushing panicky-clone");
stack.push_cloned(&[DropDetector(3)]).unwrap();
}