ffi: convert-to-foreign-string: ensure a cstring

The function operates on base_string while if it was supplied with an extended
string then ecl_base_char array became ecl_character, and that lead to bad
copies. To fix it we ensure that the passes string is first coerced to cstring.
This commit is contained in:
Daniel Kochmański 2025-08-11 09:16:00 +02:00
parent 77ceb401f9
commit fad7073f10

View file

@ -473,9 +473,9 @@ translate ASCII and binary strings."
Converts a Lisp string to a foreign string. Memory should be freed Converts a Lisp string to a foreign string. Memory should be freed
with free-foreign-object." with free-foreign-object."
(let ((lisp-string (string string-designator)) (let ((cstring (convert-to-cstring (string string-designator)))
(foreign-type '(* :char))) (foreign-type '(* :char)))
(c-inline (lisp-string foreign-type) (t t) t (c-inline (cstring foreign-type) (t t) t
"{ "{
cl_object lisp_string = #0; cl_object lisp_string = #0;
cl_index size = lisp_string->base_string.fillp; cl_index size = lisp_string->base_string.fillp;