commit 975585b00a3548b6445415f73ad368b8dcce82cd
parent e5af907da4402212f37151c50fe61f8d13ab615f
Author: Andres Navarro <canavarro82@gmail.com>
Date: Sat, 9 Apr 2011 23:35:56 -0300
Bugfix: added one to the buf size in bigint printing to negative numbers (for '-'). It still worked because of the extra value added for safety in print_size.
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/kwrite.c b/src/kwrite.c
@@ -40,9 +40,10 @@ void kwrite_error(klisp_State *K, char *msg)
void kw_print_bigint(klisp_State *K, TValue bigint)
{
- /* XXX: calculate appropiate size & malloc string,
- leave space for sign */
- int32_t size = kbigint_print_size(bigint, 10);
+ int32_t size = kbigint_print_size(bigint, 10) +
+ (kbigint_negativep(bigint))? 1 : 0;
+
+
TValue buf_str = kstring_new_g(K, size);
/* write backwards so we can use printf later */
char *buf = kstring_buf(buf_str) + size - 1;