summaryrefslogtreecommitdiffstats
path: root/tests/017
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-05-17 20:52:44 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-05-17 20:52:44 -0700
commitdd9ab5fc0b6c0b706288f8f5e20989b6e24921e9 (patch)
treec58d46d42e22737ae2a7d97df3c16802b3217925 /tests/017
parent84f3ab45a75a881cf7959edd381bbcd0ee828ed5 (diff)
downloadtxr-dd9ab5fc0b6c0b706288f8f5e20989b6e24921e9.tar.gz
txr-dd9ab5fc0b6c0b706288f8f5e20989b6e24921e9.tar.bz2
txr-dd9ab5fc0b6c0b706288f8f5e20989b6e24921e9.zip
ffi: bugfix: null terminated string as flexible member.
* ffi.c (ffi_char_array_get, ffi_zchar_array_get, ffi_wchar_array_get, ffi_bchar_array_get): Rearrange so that we test for tft->null_term first, and not nelem == 0. If nelem happens to be zero, but we are supposed to decode a null-terminated string, we will do the wrong thing and return the null string. (ffi_varray_in): The body can't be conditional on vec being non-nil, because then we do nothing if we don't have a Lisp object, which means we skip the cases when we should decode a null-terminated array. Now if vec is nil, we must guard against calling ffi_varray_dynsize.
Diffstat (limited to 'tests/017')
-rw-r--r--tests/017/ffi-misc.tl6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/017/ffi-misc.tl b/tests/017/ffi-misc.tl
index 7053f78e..d0785513 100644
--- a/tests/017/ffi-misc.tl
+++ b/tests/017/ffi-misc.tl
@@ -88,3 +88,9 @@
(copy-cptr (cptr-int 3)) "#<cptr: 3>"
(copy (cptr-int 3)) "#<cptr: 3>"
(copy-cptr 3) :error)
+
+(ffi (struct flex (x char) (y (zarray char))))
+
+(mtest
+ (ffi-put (new flex x #\a y "bcd") (ffi (struct flex))) #b'6100000062636400'
+ (ffi-get #b'6100000062636400' (ffi (struct flex))) #S(flex x #\a y "bcd"))