diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-03 17:22:29 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-03 17:22:29 +0000 |
commit | fc64f8c5fe0bdbd69b2b55bfb8d1ade653714f53 (patch) | |
tree | 862f1d67fab17b790dd0f551812618e476dfdbc4 | |
parent | 3643afcc45ad9cf7d1e01da9fc1203bd5bbf87e5 (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/trunk@17861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | numeric.c | 12 |
2 files changed, 9 insertions, 8 deletions
@@ -1,3 +1,8 @@ +Fri Jul 4 02:21:06 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 23:26:36 2008 Yusuke Endoh <mame@tsg.ne.jp> * include/ruby/intern.h: remove prototypes about coverage. @@ -1585,10 +1585,10 @@ check_int(SIGNED_VALUE num) } static void -check_uint(VALUE num) +check_uint(VALUE num, int sign) { if (num > UINT_MAX) { - rb_raise(rb_eRangeError, "integer %"PRIuVALUE " too big to convert to `unsigned int'", num); + rb_raise(rb_eRangeError, "integer %"PRIuVALUE " too %s to convert to `unsigned int'", num, sign ? "small" : "big"); } } @@ -1615,9 +1615,7 @@ rb_num2uint(VALUE 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, '<', INT2FIX(0)))); return num; } @@ -1630,9 +1628,7 @@ rb_fix2uint(VALUE 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 |