Skip to content

Commit

Permalink
Fix Segfault in OwnedEnv::send_and_clear
Browse files Browse the repository at this point in the history
  • Loading branch information
scrogson authored and hansihe committed Jan 6, 2020
1 parent 96e6721 commit 27c2160
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rustler/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ impl OwnedEnv {

let message = self.run(|env| closure(env).as_c_arg());

let c_env = *self.env;
self.env = Arc::new(c_env); // invalidate SavedTerms
unsafe {
rustler_sys::enif_send(ptr::null_mut(), recipient.as_c_arg(), c_env, message);
rustler_sys::enif_send(ptr::null_mut(), recipient.as_c_arg(), *self.env, message);
}

self.clear();
}

/// Free all terms in this environment and clear it for reuse.
Expand Down

0 comments on commit 27c2160

Please sign in to comment.