Skip to content

Commit

Permalink
Fix double free issue for non-pointer field
Browse files Browse the repository at this point in the history
  • Loading branch information
CoorFun committed Mar 18, 2020
1 parent 8e78963 commit df307de
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ffi-convert-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ffi-convert-derive"
version = "0.1.0"
version = "0.1.1"
authors = ["Sonos"]
edition = "2018"
license = "MIT OR Apache-2.0"
Expand Down
9 changes: 4 additions & 5 deletions ffi-convert-derive/src/cdrop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ pub fn impl_cdrop_macro(input: &syn::DeriveInput) -> TokenStream {

let drop_field = if field.is_string {
quote!(ffi_convert::take_back_c_string!(self.#field_name))
} else if field.is_pointer {
quote!( unsafe { #field_type::drop_raw_pointer(self.#field_name) }? )
} else {
if field.is_pointer {
quote!( unsafe { #field_type::drop_raw_pointer(self.#field_name) }? )
} else {
quote!( self.# field_name.do_drop()? )
}
// the other cases will be handled automatically by rust
quote!()
};

let conversion = if field.is_nullable {
Expand Down
4 changes: 2 additions & 2 deletions ffi-convert-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "ffi-convert-tests"
version = "0.1.0"
version = "0.1.1"
authors = ["Sonos"]
edition = "2018"

[dependencies]
failure = "0.1"
ffi-convert = "0.1"
ffi-convert = "0.1.1"
libc = "0.2.66"
4 changes: 2 additions & 2 deletions ffi-convert/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ffi-convert"
version = "0.1.0"
version = "0.1.1"
authors = ["Sonos"]
edition = "2018"
license = "MIT OR Apache-2.0"
Expand All @@ -10,6 +10,6 @@ readme = "../README.md"
keywords = ["ffi"]

[dependencies]
ffi-convert-derive = "0.1"
ffi-convert-derive = "0.1.1"
failure = "0.1"
libc = "0.2"

0 comments on commit df307de

Please sign in to comment.