diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-05-04 21:49:20 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-05-04 21:49:20 -0700 |
commit | 9e25825ca0babfa50a8e21ba2b842ca20e9935b3 (patch) | |
tree | 3f196295698c295f599e9b7470808256d2204558 /ffi.c | |
parent | deb94c615bda4430b3d71eb2f961fbc09cfab9da (diff) | |
download | txr-9e25825ca0babfa50a8e21ba2b842ca20e9935b3.tar.gz txr-9e25825ca0babfa50a8e21ba2b842ca20e9935b3.tar.bz2 txr-9e25825ca0babfa50a8e21ba2b842ca20e9935b3.zip |
ffi: check array dimensions.
* ffi.c (ffi_type_compile): Throw error if the dimension
is negative in any array operator, or also if it is zero in a
zarray operator.
Diffstat (limited to 'ffi.c')
-rw-r--r-- | ffi.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -1310,11 +1310,21 @@ val ffi_type_compile(val syntax) val eltype_syntax = caddr(syntax); val eltype = ffi_type_compile(eltype_syntax); + if (minusp(dim)) + uw_throwf(error_s, lit("~a: negative dimension in ~s"), + self, syntax, nao); + { val type = make_ffi_type_array(syntax, vec_s, dim, eltype); struct txr_ffi_type *tft = ffi_type_struct(type); - if (sym == zarray_s) + + if (sym == zarray_s) { tft->null_term = 1; + if (zerop(dim)) + uw_throwf(error_s, lit("~a: zero dimension in ~s"), + self, syntax, nao); + } + if (eltype_syntax == char_s) tft->char_conv = 1; else if (eltype_syntax == wchar_s) |