From a31c317fb59964be6ab4414fbaea4abebef1c0f5 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 3 Nov 2014 21:34:24 +0100 Subject: [PATCH] FFI: No meta fallback when indexing pointer to incomplete struct. --- src/lj_cdata.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lj_cdata.c b/src/lj_cdata.c index 590ddf10..ebaea6d2 100644 --- a/src/lj_cdata.c +++ b/src/lj_cdata.c @@ -127,16 +127,16 @@ collect_attrib: integer_key: if (ctype_ispointer(ct->info)) { CTSize sz = lj_ctype_size(cts, ctype_cid(ct->info)); /* Element size. */ - if (sz != CTSIZE_INVALID) { - if (ctype_isptr(ct->info)) { - p = (uint8_t *)cdata_getptr(p, ct->size); - } else if ((ct->info & (CTF_VECTOR|CTF_COMPLEX))) { - if ((ct->info & CTF_COMPLEX)) idx &= 1; - *qual |= CTF_CONST; /* Valarray elements are constant. */ - } - *pp = p + idx*(int32_t)sz; - return ct; + if (sz == CTSIZE_INVALID) + lj_err_caller(cts->L, LJ_ERR_FFI_INVSIZE); + if (ctype_isptr(ct->info)) { + p = (uint8_t *)cdata_getptr(p, ct->size); + } else if ((ct->info & (CTF_VECTOR|CTF_COMPLEX))) { + if ((ct->info & CTF_COMPLEX)) idx &= 1; + *qual |= CTF_CONST; /* Valarray elements are constant. */ } + *pp = p + idx*(int32_t)sz; + return ct; } } else if (tviscdata(key)) { /* Integer cdata key. */ GCcdata *cdk = cdataV(key);