Skip to content

Commit

Permalink
native: Take back the EventSender to avoid leakage
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinnerbone authored and torokati44 committed Mar 13, 2024
1 parent 7e2bd09 commit dd1b888
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions native/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,16 @@ fn run(app: AndroidApp) {
}
}
}

unsafe {
let vm = JavaVM::from_raw(app.vm_as_ptr() as *mut sys::JavaVM).expect("JVM must exist");
let activity = JObject::from_raw(app.activity_as_ptr() as jobject);
// Ensure that we take the EventSender back, or we'll leak it
let _: Result<EventSender, _> = vm
.get_env()
.unwrap()
.take_rust_field(activity, "eventLoopHandle");
}
}

#[no_mangle]
Expand Down

0 comments on commit dd1b888

Please sign in to comment.