diff options
Diffstat (limited to 'src/lib_ffi.c')
-rw-r--r-- | src/lib_ffi.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib_ffi.c b/src/lib_ffi.c index c674582d..414f1d2f 100644 --- a/src/lib_ffi.c +++ b/src/lib_ffi.c | |||
@@ -123,7 +123,8 @@ LJLIB_CF(ffi_meta___index) LJLIB_REC(cdata_index 0) | |||
123 | if (!(o+1 < L->top && tviscdata(o))) /* Also checks for presence of key. */ | 123 | if (!(o+1 < L->top && tviscdata(o))) /* Also checks for presence of key. */ |
124 | lj_err_argt(L, 1, LUA_TCDATA); | 124 | lj_err_argt(L, 1, LUA_TCDATA); |
125 | ct = lj_cdata_index(cts, cdataV(o), o+1, &p, &qual); | 125 | ct = lj_cdata_index(cts, cdataV(o), o+1, &p, &qual); |
126 | lj_cdata_get(cts, ct, L->top-1, p); | 126 | if (lj_cdata_get(cts, ct, L->top-1, p)) |
127 | lj_gc_check(L); | ||
127 | return 1; | 128 | return 1; |
128 | } | 129 | } |
129 | 130 | ||
@@ -210,6 +211,7 @@ static int ffi_arith_ptr(lua_State *L, CTState *cts, FFIArith *fa, MMS mm) | |||
210 | cd = lj_cdata_new(cts, id, CTSIZE_PTR); | 211 | cd = lj_cdata_new(cts, id, CTSIZE_PTR); |
211 | *(uint8_t **)cdataptr(cd) = pp; | 212 | *(uint8_t **)cdataptr(cd) = pp; |
212 | setcdataV(L, L->top-1, cd); | 213 | setcdataV(L, L->top-1, cd); |
214 | lj_gc_check(L); | ||
213 | return 1; | 215 | return 1; |
214 | } | 216 | } |
215 | 217 | ||
@@ -265,6 +267,7 @@ static int ffi_arith_int64(lua_State *L, CTState *cts, FFIArith *fa, MMS mm) | |||
265 | case MM_unm: *up = -u0; break; | 267 | case MM_unm: *up = -u0; break; |
266 | default: lua_assert(0); break; | 268 | default: lua_assert(0); break; |
267 | } | 269 | } |
270 | lj_gc_check(L); | ||
268 | return 1; | 271 | return 1; |
269 | } | 272 | } |
270 | return 0; | 273 | return 0; |
@@ -335,14 +338,16 @@ LJLIB_CF(ffi_meta___tostring) | |||
335 | CType *ct = ctype_raw(ctype_cts(L), id); | 338 | CType *ct = ctype_raw(ctype_cts(L), id); |
336 | if (ctype_iscomplex(ct->info)) { | 339 | if (ctype_iscomplex(ct->info)) { |
337 | setstrV(L, L->top-1, lj_ctype_repr_complex(L, cdataptr(cd), ct->size)); | 340 | setstrV(L, L->top-1, lj_ctype_repr_complex(L, cdataptr(cd), ct->size)); |
338 | return 1; | 341 | goto checkgc; |
339 | } else if (ct->size == 8 && ctype_isinteger(ct->info)) { | 342 | } else if (ct->size == 8 && ctype_isinteger(ct->info)) { |
340 | setstrV(L, L->top-1, lj_ctype_repr_int64(L, *(uint64_t *)cdataptr(cd), | 343 | setstrV(L, L->top-1, lj_ctype_repr_int64(L, *(uint64_t *)cdataptr(cd), |
341 | (ct->info & CTF_UNSIGNED))); | 344 | (ct->info & CTF_UNSIGNED))); |
342 | return 1; | 345 | goto checkgc; |
343 | } | 346 | } |
344 | } | 347 | } |
345 | lj_str_pushf(L, msg, strdata(lj_ctype_repr(L, id, NULL)), cdataptr(cd)); | 348 | lj_str_pushf(L, msg, strdata(lj_ctype_repr(L, id, NULL)), cdataptr(cd)); |
349 | checkgc: | ||
350 | lj_gc_check(L); | ||
346 | return 1; | 351 | return 1; |
347 | } | 352 | } |
348 | 353 | ||
@@ -402,6 +407,7 @@ LJLIB_CF(ffi_typeof) | |||
402 | GCcdata *cd = lj_cdata_new(cts, CTID_CTYPEID, 4); | 407 | GCcdata *cd = lj_cdata_new(cts, CTID_CTYPEID, 4); |
403 | *(CTypeID *)cdataptr(cd) = id; | 408 | *(CTypeID *)cdataptr(cd) = id; |
404 | setcdataV(L, L->top-1, cd); | 409 | setcdataV(L, L->top-1, cd); |
410 | lj_gc_check(L); | ||
405 | return 1; | 411 | return 1; |
406 | } | 412 | } |
407 | 413 | ||