diff options
| author | Mike Pall <mike> | 2025-11-10 18:15:11 +0100 |
|---|---|---|
| committer | Mike Pall <mike> | 2025-11-10 18:15:11 +0100 |
| commit | c94312d348e3530b369b4e517fce4c65df6cd270 (patch) | |
| tree | 26b14c738a7368cdde01b660bd791ff270545569 /src | |
| parent | c92d0cb19263e7e302b4740ba6617a32c201c613 (diff) | |
| download | luajit-c94312d348e3530b369b4e517fce4c65df6cd270.tar.gz luajit-c94312d348e3530b369b4e517fce4c65df6cd270.tar.bz2 luajit-c94312d348e3530b369b4e517fce4c65df6cd270.zip | |
FFI: Avoid dangling cts->L.
Reported by ZumiKua. #1405
Diffstat (limited to 'src')
| -rw-r--r-- | src/lj_state.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lj_state.c b/src/lj_state.c index ecf15198..18a55e72 100644 --- a/src/lj_state.c +++ b/src/lj_state.c | |||
| @@ -304,6 +304,10 @@ lua_State *lj_state_new(lua_State *L) | |||
| 304 | void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L) | 304 | void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L) |
| 305 | { | 305 | { |
| 306 | lua_assert(L != mainthread(g)); | 306 | lua_assert(L != mainthread(g)); |
| 307 | #if LJ_HASFFI | ||
| 308 | if (ctype_ctsG(g) && ctype_ctsG(g)->L == L) /* Avoid dangling cts->L. */ | ||
| 309 | ctype_ctsG(g)->L = mainthread(g); | ||
| 310 | #endif | ||
| 307 | lj_func_closeuv(L, tvref(L->stack)); | 311 | lj_func_closeuv(L, tvref(L->stack)); |
| 308 | lua_assert(gcref(L->openupval) == NULL); | 312 | lua_assert(gcref(L->openupval) == NULL); |
| 309 | lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); | 313 | lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); |
