diff options
author | Lars Kanis <lars@greiz-reinsdorf.de> | 2020-07-10 18:56:13 +0200 |
---|---|---|
committer | Lars Kanis <lars@greiz-reinsdorf.de> | 2020-08-03 21:30:48 +0200 |
commit | f9b0986ac7586188e67e432abca35c1561cc8658 (patch) | |
tree | 92dc03c59ccf3a23a26e8dbbd4d4ec4aeceeecef /spec | |
parent | 29e7467bfcc574c3724b2e77b38e0fd95832bb87 (diff) | |
download | ffi-f9b0986ac7586188e67e432abca35c1561cc8658.tar.gz |
Do NULL pointer check only when array length > 0
This changes array read and write methods to no longer raise a FFI::NullPointerError if there is actually no memory access.
Fixes #305
Diffstat (limited to 'spec')
-rw-r--r-- | spec/ffi/pointer_spec.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/spec/ffi/pointer_spec.rb b/spec/ffi/pointer_spec.rb index 97f3c5f..97954cd 100644 --- a/spec/ffi/pointer_spec.rb +++ b/spec/ffi/pointer_spec.rb @@ -143,6 +143,11 @@ describe "Pointer" do it 'returns true when compared with nil' do expect((FFI::Pointer::NULL == nil)).to be true end + it 'should not raise an error when attempting read/write zero length array' do + null_ptr = FFI::Pointer::NULL + expect( null_ptr.read_array_of_uint(0) ).to eq([]) + null_ptr.write_array_of_uint([]) + end end it "Pointer.size returns sizeof pointer on platform" do |