FFI: Fix argument checks for ffi.string().

This commit is contained in:
Mike Pall 2013-09-08 03:09:39 +02:00
parent b6ec7c7c86
commit 93c2b939bd
2 changed files with 2 additions and 2 deletions

View File

@ -657,7 +657,7 @@ LJLIB_CF(ffi_string) LJLIB_REC(.)
TValue *o = lj_lib_checkany(L, 1);
const char *p;
size_t len;
if (o+1 < L->top) {
if (o+1 < L->top && !tvisnil(o+1)) {
len = (size_t)ffi_checkint(L, 2);
lj_cconv_ct_tv(cts, ctype_get(cts, CTID_P_CVOID), (uint8_t *)&p, o,
CCF_ARG(1));

View File

@ -1514,7 +1514,7 @@ void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd)
TRef tr = J->base[0];
if (tr) {
TRef trlen = J->base[1];
if (trlen) {
if (!tref_isnil(trlen)) {
trlen = crec_toint(J, cts, trlen, &rd->argv[1]);
tr = crec_ct_tv(J, ctype_get(cts, CTID_P_CVOID), 0, tr, &rd->argv[0]);
} else {