Skip to content
Browse files

Fix for JRUBY-1848 by Vladimir.

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@5443 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
1 parent 3b5495b commit 7f0e7fa6622f2ed8d1a7427a4b74303ed71a2b84 @headius headius committed Dec 30, 2007
Showing with 7 additions and 3 deletions.
  1. +3 −3 src/org/jruby/RubyBignum.java
  2. +4 −0 test/test_bignum.rb
View
6 src/org/jruby/RubyBignum.java
@@ -476,12 +476,12 @@ public RubyFixnum op_aref(IRubyObject other) {
}
return RubyFixnum.one(getRuntime());
}
- int position = num2int(other);
- if (position < 0) {
+ long position = num2long(other);
+ if (position < 0 || position > Integer.MAX_VALUE) {
return RubyFixnum.zero(getRuntime());
}
- return value.testBit(num2int(other)) ? RubyFixnum.one(getRuntime()) : RubyFixnum.zero(getRuntime());
+ return value.testBit((int)position) ? RubyFixnum.one(getRuntime()) : RubyFixnum.zero(getRuntime());
}
/** rb_big_cmp
View
4 test/test_bignum.rb
@@ -37,6 +37,10 @@ def test_bignum_should_respond_to_array_operator
assert_equal(-(@big2)[0],-1)
assert_equal(-(@big2)[1],0)
end
+
+ def test_bignum_aref_with_bignum_arg_no_exception
+ assert_equal(0, (2**64)[2**32])
+ end
# more to come
end

0 comments on commit 7f0e7fa

Please sign in to comment.
Something went wrong with that request. Please try again.