1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-29 08:20:20 +02:00

Fix malloc/scm_c_take_bytevector mismatch.

* libguile/bytevectors.c (STRING_TO_UTF): Use `make_bytevector ()'
  instead of `scm_c_take_bytevector ().
  (scm_string_to_utf8): Likewise.
This commit is contained in:
Ludovic Courtès 2009-08-18 00:09:26 +02:00
parent fbb857a472
commit 1ac8a47f01

View file

@ -1895,9 +1895,18 @@ utf_encoding_name (char *name, size_t utf_width, SCM endianness)
scm_syserror_msg (FUNC_NAME, "failed to convert string: ~A", \
scm_list_1 (str), err); \
else \
/* C_UTF is null-terminated. */ \
utf = scm_c_take_bytevector ((signed char *) c_utf, \
c_utf_len); \
{ \
/* C_UTF is null-terminated. It is malloc(3)-allocated, so we cannot \
use `scm_c_take_bytevector ()'. */ \
scm_dynwind_begin (0); \
scm_dynwind_free (c_utf); \
\
utf = make_bytevector (c_utf_len); \
memcpy (SCM_BYTEVECTOR_CONTENTS (utf), c_utf, \
c_utf_len); \
\
scm_dynwind_end (); \
} \
\
return (utf);
@ -1931,9 +1940,18 @@ SCM_DEFINE (scm_string_to_utf8, "string->utf8",
if (SCM_UNLIKELY (c_utf == NULL))
scm_syserror (FUNC_NAME);
else
/* C_UTF is null-terminated. */
utf = scm_c_take_bytevector ((signed char *) c_utf,
UTF_STRLEN (8, c_utf));
{
/* C_UTF is null-terminated. It is malloc(3)-allocated, so we cannot
use `scm_c_take_bytevector ()'. */
scm_dynwind_begin (0);
scm_dynwind_free (c_utf);
utf = make_bytevector (UTF_STRLEN (8, c_utf));
memcpy (SCM_BYTEVECTOR_CONTENTS (utf), c_utf,
UTF_STRLEN (8, c_utf));
scm_dynwind_end ();
}
return (utf);
}