summaryrefslogtreecommitdiffstats
path: root/ffi.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-05-20 07:30:27 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-05-20 07:30:27 -0700
commit92f85ff3b8a5ff6da61dd8ea2710e16a017fafbc (patch)
tree561d2081b6af0363421e68f534b72b07baf96356 /ffi.c
parent1210bfa2ff6c6240b87bda802bde238dfe876269 (diff)
downloadtxr-92f85ff3b8a5ff6da61dd8ea2710e16a017fafbc.tar.gz
txr-92f85ff3b8a5ff6da61dd8ea2710e16a017fafbc.tar.bz2
txr-92f85ff3b8a5ff6da61dd8ea2710e16a017fafbc.zip
ffi: diagnose carray of incomplete type.
* ffi.c (carray_buf): Do not allow an element type with zero size; throw an exception.
Diffstat (limited to 'ffi.c')
-rw-r--r--ffi.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/ffi.c b/ffi.c
index c8819faf..6dfd663c 100644
--- a/ffi.c
+++ b/ffi.c
@@ -2612,6 +2612,10 @@ val carray_buf(val buf, val type)
cnum blen = c_num(length_buf(buf));
struct txr_ffi_type *tft = ffi_type_struct(type);
cnum nelem = if3(tft->size, blen / tft->size, 0);
+ if (tft->size == 0)
+ uw_throwf(error_s,
+ lit("~a: incomplete type ~s cannot be carray element"),
+ self, tft->syntax, nao);
return make_carray(type, data, nelem, buf);
}