summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--bignum.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 7acde96a5c..ab05bc93ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Aug 1 21:02:48 2013 Tanaka Akira <akr@fsij.org>
+
+ * bignum.c (rb_big2str1): Raise an error for too big number.
+
Thu Aug 1 20:46:29 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (power_cache_get_power): Hide cached Bignum objects.
diff --git a/bignum.c b/bignum.c
index c8de1fa74f..1bde7dab6e 100644
--- a/bignum.c
+++ b/bignum.c
@@ -4366,6 +4366,10 @@ rb_big2str1(VALUE x, int base)
if (base < 2 || 36 < base)
rb_raise(rb_eArgError, "invalid radix %d", base);
+ if (RBIGNUM_LEN(x) >= LONG_MAX/BITSPERDIG) {
+ rb_raise(rb_eRangeError, "bignum too big to convert into `string'");
+ }
+
if (POW2_P(base)) {
/* base == 2 || base == 4 || base == 8 || base == 16 || base == 32 */
return big2str_base_powerof2(x, base);