diff --git a/src/ic-cdk/src/api/call.rs b/src/ic-cdk/src/api/call.rs index ca6fbac36..2fd130210 100644 --- a/src/ic-cdk/src/api/call.rs +++ b/src/ic-cdk/src/api/call.rs @@ -74,7 +74,6 @@ impl> Future for CallFuture { fn poll(self: Pin<&mut Self>, context: &mut Context<'_>) -> Poll { 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() { @@ -85,6 +84,7 @@ impl> Future for CallFuture { 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.