summaryrefslogtreecommitdiffstats
path: root/libtommath/bn_mp_radix_size.c
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2005-05-10 17:20:39 (GMT)
committerKevin B Kenny <kennykb@acm.org>2005-05-10 17:20:39 (GMT)
commit5b510b75ec4a1d6fb55691bcf55dbf4b0b936624 (patch)
tree2a8c6a5370bc1ab79e9ed6d477146fe18604eb59 /libtommath/bn_mp_radix_size.c
parent6bc86f4b98c36219302ec99939666f84264bc4da (diff)
downloadtcl-5b510b75ec4a1d6fb55691bcf55dbf4b0b936624.zip
tcl-5b510b75ec4a1d6fb55691bcf55dbf4b0b936624.tar.gz
tcl-5b510b75ec4a1d6fb55691bcf55dbf4b0b936624.tar.bz2
committed local libtommath changes from kennykb-numerics-branch back to the Tcl HEAD
Diffstat (limited to 'libtommath/bn_mp_radix_size.c')
-rw-r--r--libtommath/bn_mp_radix_size.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/libtommath/bn_mp_radix_size.c b/libtommath/bn_mp_radix_size.c
index 3d423ba..29b1d22 100644
--- a/libtommath/bn_mp_radix_size.c
+++ b/libtommath/bn_mp_radix_size.c
@@ -66,8 +66,17 @@ int mp_radix_size (mp_int * a, int radix, int *size)
}
mp_clear (&t);
- /* return digs + 1, the 1 is for the NULL byte that would be required. */
- *size = digs + 1;
+ /*
+ * return digs + 1, the 1 is for the NULL byte that would be required.
+ * mp_toradix_n requires a minimum of 3 bytes, so never report less than
+ * that.
+ */
+
+ if ( digs >= 2 ) {
+ *size = digs + 1;
+ } else {
+ *size = 3;
+ }
return MP_OKAY;
}