Skip to content

Commit

Permalink
fix associated data leak
Browse files Browse the repository at this point in the history
  • Loading branch information
bjcscat committed Dec 5, 2024
1 parent f0cd3ef commit 8055ff2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
cell::Cell,
ffi::{c_int, CString},
os::raw::c_void,
ptr::{null, null_mut},
ptr::{drop_in_place, null, null_mut},
slice,
};

Expand Down Expand Up @@ -881,6 +881,11 @@ impl Drop for Luau {
}

unsafe {
let mut associated: *mut AssociatedData = null_mut();
lua_getallocf(self.state, &raw mut associated as _);

let associated_owned = Box::from_raw(associated);

lua_close(self.state);
}
}
Expand Down

0 comments on commit 8055ff2

Please sign in to comment.