Skip to content

Commit

Permalink
Leak processed_args so that glkunix_startup_code can save the args fo…
Browse files Browse the repository at this point in the history
…r later use
  • Loading branch information
curiousdannii committed Mar 28, 2024
1 parent 9250fe2 commit 9c8e620
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion remglk_capi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ extern "C" fn main(argc: c_int, argv: *const *const c_char) -> c_int {
// We can now hand control over to the app
if unsafe{glkunix_startup_code(&GlkUnixArguments {
count: processed_args.len() as c_int,
args: processed_args.iter().map(|arg| arg.as_ptr()).collect::<Vec<*const c_char>>().as_ptr(),
// We need to leak processed_args so that the app can save the args for later use
args: processed_args.into_iter().map(|arg| arg.into_raw().cast_const()).collect::<Vec<*const c_char>>().leak().as_ptr(),
})} == 0 {
glk_exit();
return 0;
Expand Down

0 comments on commit 9c8e620

Please sign in to comment.