Skip to content

Commit

Permalink
Update test case that can trigger double free bug
Browse files Browse the repository at this point in the history
  • Loading branch information
CoorFun committed Mar 18, 2020
1 parent 52782a9 commit 8e78963
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions ffi-convert-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ pub struct CLayer {
#[derive(Clone, Debug, PartialEq)]
pub struct Dummy {
pub count: i32,
pub describe: String,
}

#[repr(C)]
#[derive(CReprOf, AsRust, CDrop)]
#[target_type(Dummy)]
pub struct CDummy {
count: i32,
describe: *const libc::c_char,
}

#[cfg(test)]
Expand All @@ -123,7 +125,12 @@ mod tests {
Topping { amount: 2 }
});

generate_round_trip_rust_c_rust!(round_trip_dummy, Dummy, CDummy, { Dummy { count: 2 } });
generate_round_trip_rust_c_rust!(round_trip_dummy, Dummy, CDummy, {
Dummy {
count: 2,
describe: "yo".to_string(),
}
});

generate_round_trip_rust_c_rust!(round_trip_layer, Layer, CLayer, {
Layer {
Expand All @@ -138,7 +145,10 @@ mod tests {
description: Some("I'm delicious ! ".to_string()),
start: 0.0,
end: Some(2.0),
dummy: Dummy { count: 2 },
dummy: Dummy {
count: 2,
describe: "yo".to_string(),
},
sauce: Some(Sauce { volume: 32.23 }),
toppings: vec![Topping { amount: 2 }, Topping { amount: 3 }],
layers: Some(vec![Layer {
Expand All @@ -155,7 +165,10 @@ mod tests {
description: Some("I'm delicious ! ".to_string()),
start: 0.0,
end: None,
dummy: Dummy { count: 2 },
dummy: Dummy {
count: 2,
describe: "yo".to_string(),
},
sauce: None,
toppings: vec![],
layers: Some(vec![]),
Expand Down

0 comments on commit 8e78963

Please sign in to comment.