Skip to content

Commit 3a5c4e2

Browse files
committed
Ensure that the mono parameters survive long enough
1 parent bcaeee9 commit 3a5c4e2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

clr_loader/mono.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ def __call__(self, ptr, size):
6464
exception = ffi.new("MonoObject**")
6565
params = ffi.new("void*[2]")
6666

67-
params[0] = ffi.new("void**", ptr)
68-
params[1] = ffi.new("int*", size)
67+
# Keep these alive until the function is called by assigning them locally
68+
ptr_ptr = ffi.new("void**", ptr)
69+
size_ptr = ffi.new("int32_t*", size)
70+
71+
params[0] = ptr_ptr
72+
params[1] = size_ptr
6973

7074
res = _MONO.mono_runtime_invoke(self._ptr, ffi.NULL, params, exception)
7175
_check_result(res, "Failed to call method")

0 commit comments

Comments
 (0)