summaryrefslogtreecommitdiffstats
path: root/ffi.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-05-10 20:20:12 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-05-10 20:20:12 -0700
commitb829bb25d84940ee1d04d6e4983bb06d29091a29 (patch)
treeaf986b26080a4c04728437386e5ba770f03bc4ef /ffi.c
parent2e0385880600fb0edee85a8960ed3160086a42f1 (diff)
downloadtxr-b829bb25d84940ee1d04d6e4983bb06d29091a29.tar.gz
txr-b829bb25d84940ee1d04d6e4983bb06d29091a29.tar.bz2
txr-b829bb25d84940ee1d04d6e4983bb06d29091a29.zip
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.
Diffstat (limited to 'ffi.c')
-rw-r--r--ffi.c8
1 files 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);