diff --git a/src/asm_based.rs b/src/asm_based.rs index 0329b1a..dfe2b7d 100644 --- a/src/asm_based.rs +++ b/src/asm_based.rs @@ -129,6 +129,11 @@ where where F: for<'a> FnOnce(&'a JmpBufFields) -> c_int, { + // Dereference `closure_env_ptr` with .read() to acquire ownership of + // the FnOnce object, then call it. (See also the forget note below.) + // + // Note that `closure_env_ptr` is not a raw function pointer, it's a + // pointer to a FnOnce; the code we call comes from the generic `F`. unsafe { (closure_env_ptr.read())(&*jbuf) } } unsafe { @@ -173,6 +178,11 @@ where where F: for<'a> FnOnce(&'a SigJmpBufFields) -> c_int, { + // Dereference `closure_env_ptr` with .read() to acquire ownership of + // the FnOnce object, then call it. (See also the forget note below.) + // + // Note that `closure_env_ptr` is not a raw function pointer, it's a + // pointer to a FnOnce; the code we call comes from the generic `F`. unsafe { (closure_env_ptr.read())(&*jbuf) } } diff --git a/src/cee_based.rs b/src/cee_based.rs index 11646c8..ee5172f 100644 --- a/src/cee_based.rs +++ b/src/cee_based.rs @@ -20,6 +20,12 @@ where F: for<'a> FnOnce(&'a JmpBufFields) -> c_int, { let closure_env_ptr: *mut F = closure_env_ptr as *mut F; + + // Dereference `closure_env_ptr` with .read() to acquire ownership of + // the FnOnce object, then call it. (See also the forget note below.) + // + // Note that `closure_env_ptr` is not a raw function pointer, it's a + // pointer to a FnOnce; the code we call comes from the generic `F`. unsafe { (closure_env_ptr.read())(&*jbuf) } } @@ -48,6 +54,12 @@ where F: for<'a> FnOnce(&'a SigJmpBufFields) -> c_int, { let closure_env_ptr: *mut F = closure_env_ptr as *mut F; + + // Dereference `closure_env_ptr` with .read() to acquire ownership of + // the FnOnce object, then call it. (See also the forget note below.) + // + // Note that `closure_env_ptr` is not a raw function pointer, it's a + // pointer to a FnOnce; the code we call comes from the generic `F`. unsafe { (closure_env_ptr.read())(&*jbuf) } }