Skip to content

Commit

Permalink
fix: Fix memory leak in CallFuture (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamspofford-dfinity authored Aug 16, 2024
1 parent deb1e15 commit bd17d57
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ic-cdk/src/api/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ impl<T: AsRef<[u8]>> Future for CallFuture<T> {

fn poll(self: Pin<&mut Self>, context: &mut Context<'_>) -> Poll<Self::Output> {
let self_ref = Pin::into_inner(self);
let state_ptr = Weak::into_raw(Arc::downgrade(&self_ref.state));
let mut state = self_ref.state.write().unwrap();

if let Some(result) = state.result.take() {
Expand All @@ -85,6 +84,7 @@ impl<T: AsRef<[u8]>> Future for CallFuture<T> {
let method = &state.method;
let args = state.arg.as_ref();
let payment = state.payment;
let state_ptr = Weak::into_raw(Arc::downgrade(&self_ref.state));
// SAFETY:
// `callee`, being &[u8], is a readable sequence of bytes and therefore can be passed to ic0.call_new.
// `method`, being &str, is a readable sequence of bytes and therefore can be passed to ic0.call_new.
Expand Down

0 comments on commit bd17d57

Please # to comment.