BrettMayson / arma-rs

GNU General Public License v2.0
42 stars 8 forks source link

Possible memory leakage in `run_callbacks` #21

Closed lizhuohua closed 2 years ago

lizhuohua commented 2 years ago

In function run_callbacks, string pointers are extracted from CString by using into_raw().

https://github.com/BrettMayson/arma-rs/blob/3b43d2100d64138f4fc8b5851799492bffce0e9a/arma-rs/src/lib.rs#L131

However, this also transfers ownership of the string to the C caller, which will lead to a memory leak. See the documents here: https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_raw