From a8d124d7626602c6ff44c63757d3c56e6392fc80 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku <kaz@kylheku.com> Date: Wed, 10 May 2017 22:06:19 -0700 Subject: 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. --- ffi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ffi.c') diff --git a/ffi.c b/ffi.c index cedf5934..e9592886 100644 --- a/ffi.c +++ b/ffi.c @@ -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); } -- cgit v1.2.3