Commit 6cb357e
authored
Free RustCallStatus pointer after every Rust call (#38)
The call-status pointer allocated by createPointer in makeRustCall was
never released. ffi-rs's createPointer Box-allocates non-StackStruct
values via Box::into_raw(Box::new(generate_c_struct(...))), and the
JsExternal wrapper does not free that memory on garbage collection per
ffi-rs's documented contract. Neither restorePointer nor unwrapPointer
free anything either. Result: every synchronous Rust call leaked the
RustCallStatus struct plus its wrapper Box, and method calls leaked
twice (once for clonePointer, once for the call itself).
Wrap the call site in try/finally and call freePointer with the same
struct paramsType so the allocation is reclaimed regardless of whether
the call returned normally or threw.1 parent 31ed6eb commit 6cb357e
1 file changed
Lines changed: 15 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
| 198 | + | |
| 199 | + | |
199 | 200 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
205 | 206 | | |
206 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
207 | 215 | | |
208 | 216 | | |
209 | 217 | | |
| |||
0 commit comments