From 6907f6ca4582064f28e3a58374083ab2a4d85418 Mon Sep 17 00:00:00 2001 From: Gerhard R Date: Fri, 11 May 2012 20:40:32 +0300 Subject: [PATCH] fix bug in mp_radix_size() zero values returned a length of 1, not 2 in case of radix 2 re-ordering the special casing takes care of it --- bn_mp_radix_size.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bn_mp_radix_size.c b/bn_mp_radix_size.c index 9aab94a..1cbfba3 100644 --- a/bn_mp_radix_size.c +++ b/bn_mp_radix_size.c @@ -24,12 +24,6 @@ int mp_radix_size (mp_int * a, int radix, int *size) *size = 0; - /* special case for binary */ - if (radix == 2) { - *size = mp_count_bits (a) + (a->sign == MP_NEG ? 1 : 0) + 1; - return MP_OKAY; - } - /* make sure the radix is in range */ if (radix < 2 || radix > 64) { return MP_VAL; @@ -40,6 +34,12 @@ int mp_radix_size (mp_int * a, int radix, int *size) return MP_OKAY; } + /* special case for binary */ + if (radix == 2) { + *size = mp_count_bits (a) + (a->sign == MP_NEG ? 1 : 0) + 1; + return MP_OKAY; + } + /* digs is the digit count */ digs = 0;