diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-06-05 22:28:45 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-06-05 22:28:45 -0700 |
commit | fa2318f5fb705f106bf251e2dd52f22c5c6bc5f4 (patch) | |
tree | 625ee5be6165cfe32ee83eb531690f7e25665937 /lib.c | |
parent | 43d1b6f69210064c4df8006c3a692d53e31fea64 (diff) | |
download | txr-fa2318f5fb705f106bf251e2dd52f22c5c6bc5f4.tar.gz txr-fa2318f5fb705f106bf251e2dd52f22c5c6bc5f4.tar.bz2 txr-fa2318f5fb705f106bf251e2dd52f22c5c6bc5f4.zip |
ffi: fix broken bchar array get.
* lib.c (string_8bit_size): This function must allocate an
extra wchar_t and null-terminate. That is the semantics
expected by ffi_bchar_array_get which uses it, and of
course string_own requires a null-terminated string.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -3307,9 +3307,10 @@ val string_8bit(const unsigned char *str) val string_8bit_size(const unsigned char *str, size_t sz) { size_t i; - wchar_t *wstr = chk_wmalloc(sz); + wchar_t *wstr = chk_wmalloc(sz + 1); for (i = 0; i < sz; i++) wstr[i] = str[i]; + wstr[i] = 0; return string_own(wstr); } |