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 | 3cdc2c189166dd5dc5c760dc37b318aa1df16417 (patch) | |
tree | 3f196295698c295f599e9b7470808256d2204558 | |
parent | 10c05be0117f07043a453fbbe87d119a795aacef (diff) | |
download | txr-3cdc2c189166dd5dc5c760dc37b318aa1df16417.tar.gz txr-3cdc2c189166dd5dc5c760dc37b318aa1df16417.tar.bz2 txr-3cdc2c189166dd5dc5c760dc37b318aa1df16417.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.
-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) |