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

fix `free' of mpz_to_str

* libguile/numbers.c (scm_number_to_string): Don't `free' the result of
  mpz_get_str; use the mp free function.
This commit is contained in:
Andy Wingo 2011-12-02 19:18:05 +01:00
parent 76f3ee77b0
commit d88f5323d1

View file

@ -5330,8 +5330,14 @@ SCM_DEFINE (scm_number_to_string, "number->string", 1, 1, 0,
else if (SCM_BIGP (n))
{
char *str = mpz_get_str (NULL, base, SCM_I_BIG_MPZ (n));
size_t len = strlen (str);
void (*freefunc) (void *, size_t);
SCM ret;
mp_get_memory_functions (NULL, NULL, &freefunc);
scm_remember_upto_here_1 (n);
return scm_take_locale_string (str);
ret = scm_from_latin1_stringn (str, len);
freefunc (str, len + 1);
return ret;
}
else if (SCM_FRACTIONP (n))
{