aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2012-08-12 01:16:49 +0200
committerMike Pall <mike>2012-08-12 01:16:49 +0200
commit1a3e5e1521b4e2bf861f6dc4a720808257b5a15e (patch)
treed039753e1b4d2fe9a897dd56943bd0340161863f
parentece23a4788eb4802558fae39add9ccd357e74e37 (diff)
downloadluajit-1a3e5e1521b4e2bf861f6dc4a720808257b5a15e.tar.gz
luajit-1a3e5e1521b4e2bf861f6dc4a720808257b5a15e.tar.bz2
luajit-1a3e5e1521b4e2bf861f6dc4a720808257b5a15e.zip
FFI: Don't keep CType * across call. Callback may reallocate table.
-rw-r--r--src/lj_ccall.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/lj_ccall.c b/src/lj_ccall.c
index 71331f39..392012ff 100644
--- a/src/lj_ccall.c
+++ b/src/lj_ccall.c
@@ -810,6 +810,7 @@ int lj_ccall_func(lua_State *L, GCcdata *cd)
810 int gcsteps, ret; 810 int gcsteps, ret;
811 cc.func = (void (*)(void))cdata_getptr(cdataptr(cd), sz); 811 cc.func = (void (*)(void))cdata_getptr(cdataptr(cd), sz);
812 gcsteps = ccall_set_args(L, cts, ct, &cc); 812 gcsteps = ccall_set_args(L, cts, ct, &cc);
813 ct = (CType *)((intptr_t)ct-(intptr_t)cts->tab);
813 cts->cb.slot = ~0u; 814 cts->cb.slot = ~0u;
814 lj_vm_ffi_call(&cc); 815 lj_vm_ffi_call(&cc);
815 if (cts->cb.slot != ~0u) { /* Blacklist function that called a callback. */ 816 if (cts->cb.slot != ~0u) { /* Blacklist function that called a callback. */
@@ -817,6 +818,7 @@ int lj_ccall_func(lua_State *L, GCcdata *cd)
817 setlightudV(&tv, (void *)cc.func); 818 setlightudV(&tv, (void *)cc.func);
818 setboolV(lj_tab_set(L, cts->miscmap, &tv), 1); 819 setboolV(lj_tab_set(L, cts->miscmap, &tv), 1);
819 } 820 }
821 ct = (CType *)((intptr_t)ct+(intptr_t)cts->tab); /* May be reallocated. */
820 gcsteps += ccall_get_results(L, cts, ct, &cc, &ret); 822 gcsteps += ccall_get_results(L, cts, ct, &cc, &ret);
821#if LJ_TARGET_X86 && LJ_ABI_WIN 823#if LJ_TARGET_X86 && LJ_ABI_WIN
822 /* Automatically detect __stdcall and fix up C function declaration. */ 824 /* Automatically detect __stdcall and fix up C function declaration. */