diff options
author | Frederick Cheung <frederick.cheung@gmail.com> | 2022-06-17 18:57:28 +0100 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2022-06-29 13:19:01 +0200 |
commit | 3173e3040eae7ef74e30acbad4c0fcf9d39d9667 (patch) | |
tree | e8934b7d29cbd9e12e2dce02bdd64b149e67b1be /spec/ffi | |
parent | 269e8f939e497bba749ff54ee4d79197e5c06ead (diff) | |
download | ffi-3173e3040eae7ef74e30acbad4c0fcf9d39d9667.tar.gz |
Fix Pointer#initialize using NUM2LL instead of NUM2ULL
If the high bit of the address was set this would raise RangeError
(bignum too big to convert into long long). This is not uncommon on
platforms that use the high bits of pointers for purposes such as
pointer authentication
This also now matches Pointer#address which uses ULL2NUM.
Diffstat (limited to 'spec/ffi')
-rw-r--r-- | spec/ffi/pointer_spec.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/ffi/pointer_spec.rb b/spec/ffi/pointer_spec.rb index b216a16..7a2ac15 100644 --- a/spec/ffi/pointer_spec.rb +++ b/spec/ffi/pointer_spec.rb @@ -237,6 +237,14 @@ describe "Pointer" do expect(FFI::Pointer.new(0).slice(0, 10).size_limit?).to be true end end + + describe "#initialise" do + it 'can use adresses with high bit set' do + max_address = 2**FFI::Platform::ADDRESS_SIZE - 1 + pointer = FFI::Pointer.new(:uint8, max_address) + expect(pointer.address).to eq(max_address) + end + end end describe "AutoPointer" do |