diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-05-10 22:06:19 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-05-10 22:06:19 -0700 |
commit | 489411032f7e3523d902f4d3b8225af88163d84f (patch) | |
tree | f8708a67b16a67d0d2a6952f3fdbd5eb14440879 | |
parent | c4b776f8478043bb1bfa4c506f90b3bb30acc533 (diff) | |
download | txr-489411032f7e3523d902f4d3b8225af88163d84f.tar.gz txr-489411032f7e3523d902f4d3b8225af88163d84f.tar.bz2 txr-489411032f7e3523d902f4d3b8225af88163d84f.zip |
ffi: bugfix: wrong type in allocation of varrays.
* ffi.c (ffi_varray_alloc): We must use the element type's
size, not the array's size. Also, cosmetic issue in error
message fixed.
-rw-r--r-- | ffi.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -244,9 +244,11 @@ static mem_t *ffi_fixed_alloc(struct txr_ffi_type *tft, val obj, val self) static mem_t *ffi_varray_alloc(struct txr_ffi_type *tft, val obj, val self) { ucnum len = c_unum(length(obj)); - size_t size = tft->size * len; + val eltype = tft->mtypes; + struct txr_ffi_type *etft = ffi_type_struct(eltype); + size_t size = etft->size * len; if (size < len || size < tft->size) - uw_throwf(error_s, lit("~s: array size overflow"), self, nao); + uw_throwf(error_s, lit("~a: array size overflow"), self, nao); return chk_malloc(size); } |