-
Notifications
You must be signed in to change notification settings - Fork 280
Open
Labels
bugSomething isn't workingSomething isn't working
Description
The generated wrapper main wrapping main_0 leaks the memory of args:
pub fn main() {
let mut args: Vec<*mut libc::c_char> = Vec::new();
for arg in ::std::env::args() {
println!("{:?}", arg);
args.push(
::std::ffi::CString::new(arg)
.expect("Failed to convert argument into CString.")
.into_raw(),
);
}
args.push(::std::ptr::null_mut());
unsafe {
main_0(
(args.len() - 1) as libc::c_int,
args.as_mut_ptr() as *mut *mut libc::c_char,
);
}
}We should either free it at the end by using CString::from_raw and dropping it, or by making args: Vec<CString> and then another args: Vec<*mut libc::c_char> that points to the memory owned by the first args. I think the latter approach is better.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working