Bignum#to_s doesn't check base

e$B1sF#$H?=$7$^$9!#e(B

Bignum#to_s e$B$Ne(B base e$B$NHO0O%A%’%C%/$,F0$$$F$^$;$s!#e(B

$ ./ruby -ve ‘(2**30).to_s(1)’
ruby 1.9.0 (2007-12-18 patchlevel 0) [i686-linux]
-e:1:in to_s': negative string size (or size too big) (ArgumentError) from -e:1:in

Index: bignum.c

— bignum.c (revision 14305)
+++ bignum.c (working copy)
@@ -801,7 +801,7 @@
};
long bits;

  • if (base < 2 && 36 < base)
  • if (base < 2 || 36 < base)
    rb_bug(“illegal radix %d”, base);

    if (FIXNUM_P(x)) {
    @@ -908,7 +908,7 @@
    return rb_str_new2(“0”);
    }

  • if (base < 2 && 36 < base)
  • if (base < 2 || 36 < base)
    rb_raise(rb_eArgError, “illegal radix %d”, base);

    n2 = big2str_find_n1(x, base);