summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-03 17:38:41 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-03 17:38:41 +0000
commit654a54a6645d344bcdc0399fb3384d60215754f8 (patch)
tree2dd2ecf1486697be267c660194b85c6a98fbaef0
parent3946e41bfe4ba4d650de03a358fbcc20ea24de42 (diff)
* numeric.c (check_uint, rb_num2uint): also needs checking negative
value. see [ruby-dev:33683] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--numeric.c13
2 files changed, 10 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index c8245b8b7d..72796693e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jul 4 02:38:24 2008 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * numeric.c (check_uint, rb_num2uint): also needs checking negative
+ value. see [ruby-dev:33683]
+
Thu Jul 3 19:35:45 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* ruby.c: Mac OS X needs origargc times of '\0' in
diff --git a/numeric.c b/numeric.c
index b7b60982a7..03f4afb356 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1600,11 +1600,12 @@ check_int(num)
}
static void
-check_uint(num)
+check_uint(num, sign)
unsigned long num;
+ int sign;
{
if (num > UINT_MAX) {
- rb_raise(rb_eRangeError, "integer %lu too big to convert to `unsigned int'", num);
+ rb_raise(rb_eRangeError, "integer %lu too %s to convert to `unsigned int'", num, sign ? "small" : "big");
}
}
@@ -1634,9 +1635,7 @@ rb_num2uint(val)
{
unsigned long num = rb_num2ulong(val);
- if (RTEST(rb_funcall(INT2FIX(0), '<', 1, val))) {
- check_uint(num);
- }
+ check_uint(num, RTEST(rb_funcall(val, '<', 1, INT2FIX(0))));
return num;
}
@@ -1650,9 +1649,7 @@ rb_fix2uint(val)
return rb_num2uint(val);
}
num = FIX2ULONG(val);
- if (FIX2LONG(val) > 0) {
- check_uint(num);
- }
+ check_uint(num, RTEST(rb_funcall(val, '<', INT2FIX(0))));
return num;
}
#else