summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-01 12:05:04 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-01 12:05:04 +0000
commitd620b0b9cdbca58e45033d0eaf4c14192f75f016 (patch)
tree6d3d10597a00065c8a502e9f8ef8bbf30b373bc6
parent780a125faf79ae986efe709b53304cfb7e46d964 (diff)
* bignum.c (rb_big2str1): Raise an error for too big number.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--bignum.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 7acde96..ab05bc9 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 c8de1fa..1bde7da 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);