summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-13 12:13:53 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-13 12:13:53 +0000
commit74dcda0d418c5a5eb27047cd0e4a2bf04b637834 (patch)
tree00bb0538e63771f8bf8b3babf1e26e0161e0ece0 /numeric.c
parent7724d1363582b00a322e402e220737d313fe2c0b (diff)
* numeric.c (int_chr): raise error when the value is negative.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/numeric.c b/numeric.c
index c27187f4f4..26ce683daa 100644
--- a/numeric.c
+++ b/numeric.c
@@ -2120,9 +2120,18 @@ static VALUE
int_chr(int argc, VALUE *argv, VALUE num)
{
char c;
- unsigned int i = NUM2UINT(num);
+ unsigned int i;
rb_encoding *enc;
+ if (rb_num_to_uint(num, &i) == 0) {
+ }
+ else if (FIXNUM_P(num)) {
+ rb_raise(rb_eRangeError, "%ld out of char range", FIX2LONG(num));
+ }
+ else {
+ rb_raise(rb_eRangeError, "bignum out of char range");
+ }
+
switch (argc) {
case 0:
if (0xff < i) {