From b829bb25d84940ee1d04d6e4983bb06d29091a29 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 10 May 2017 20:20:12 -0700 Subject: ffi: bugfix: use nelem, not size, in array in and get. Arrays can be varray, whose size is just pointer size. The string extraction operations shouldn't be referring to the size. * ffi.c (ffi_array_in, ffi_array_et): Use nelem instead of tft->size. --- ffi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ffi.c b/ffi.c index 7734d1dd..97b8e935 100644 --- a/ffi.c +++ b/ffi.c @@ -1011,7 +1011,7 @@ static val ffi_array_in(struct txr_ffi_type *tft, int copy, mem_t *src, if (tft->null_term) { str = string_utf8(chptr); } else { - wchar_t *wch = utf8_dup_from_buf(chptr, tft->size); + wchar_t *wch = utf8_dup_from_buf(chptr, nelem); str = string_own(wch); } } @@ -1042,7 +1042,7 @@ static val ffi_array_in(struct txr_ffi_type *tft, int copy, mem_t *src, if (tft->null_term) str = string_8bit(chptr); else - str = string_8bit_size(chptr, tft->size); + str = string_8bit_size(chptr, nelem); } vec = if3(vec, replace(vec, str, zero, t), str); } else { @@ -1131,7 +1131,7 @@ static val ffi_array_get(struct txr_ffi_type *tft, mem_t *src, val self) if (tft->null_term) { return string_utf8(chptr); } else { - wchar_t *wch = utf8_dup_from_buf(chptr, tft->size); + wchar_t *wch = utf8_dup_from_buf(chptr, tft->nelem); return string_own(wch); } } @@ -1156,7 +1156,7 @@ static val ffi_array_get(struct txr_ffi_type *tft, mem_t *src, val self) if (tft->null_term) return string_8bit(chptr); else - return string_8bit_size(chptr, tft->size); + return string_8bit_size(chptr, nelem); } } else { cnum znelem = if3(tft->null_term && nelem > 0, nelem - 1, nelem); -- cgit v1.2.3