mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-04 11:10:27 +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:
parent
fbb857a472
commit
1ac8a47f01
1 changed files with 24 additions and 6 deletions
|
@ -1895,10 +1895,19 @@ utf_encoding_name (char *name, size_t utf_width, SCM endianness)
|
||||||
scm_syserror_msg (FUNC_NAME, "failed to convert string: ~A", \
|
scm_syserror_msg (FUNC_NAME, "failed to convert string: ~A", \
|
||||||
scm_list_1 (str), err); \
|
scm_list_1 (str), err); \
|
||||||
else \
|
else \
|
||||||
/* C_UTF is null-terminated. */ \
|
{ \
|
||||||
utf = scm_c_take_bytevector ((signed char *) 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 (c_utf_len); \
|
||||||
|
memcpy (SCM_BYTEVECTOR_CONTENTS (utf), c_utf, \
|
||||||
c_utf_len); \
|
c_utf_len); \
|
||||||
\
|
\
|
||||||
|
scm_dynwind_end (); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
return (utf);
|
return (utf);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1931,10 +1940,19 @@ SCM_DEFINE (scm_string_to_utf8, "string->utf8",
|
||||||
if (SCM_UNLIKELY (c_utf == NULL))
|
if (SCM_UNLIKELY (c_utf == NULL))
|
||||||
scm_syserror (FUNC_NAME);
|
scm_syserror (FUNC_NAME);
|
||||||
else
|
else
|
||||||
/* C_UTF is null-terminated. */
|
{
|
||||||
utf = scm_c_take_bytevector ((signed char *) 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));
|
UTF_STRLEN (8, c_utf));
|
||||||
|
|
||||||
|
scm_dynwind_end ();
|
||||||
|
}
|
||||||
|
|
||||||
return (utf);
|
return (utf);
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue