summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-12-02 19:18:05 +0100
committerAndy Wingo <wingo@pobox.com>2011-12-02 19:18:05 +0100
commitd88f5323d10a09533a5b66bb8031a4e2b8e44313 (patch)
treea97e77c89a0dc2eac2bc68701d52baa3488d99ca
parent76f3ee77b07141b5ba5a199182d0e8118cd026d0 (diff)
downloadguile-d88f5323d10a09533a5b66bb8031a4e2b8e44313.tar.gz
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.
-rw-r--r--libguile/numbers.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libguile/numbers.c b/libguile/numbers.c
index e5b4ed938..693838138 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -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))
{