Skip to content

Loading…

[FFI] FFI::AutoPointer#free causes FFI::AutoPointer#autorelease? to cast NullPointerException #654

Closed
Burgestrand opened this Issue · 0 comments

1 participant

@Burgestrand
require "ffi"

class Releasable < FFI::AutoPointer
  def self.release(pointer)
    puts "Release"
    # no op
  end
end

p = FFI::Pointer.new(1)
r = Releasable.new(p)
r.free
p r.autorelease? # => NullPointerException

It’s because when AutoPointer#free is called, the reaper (managed for releasing the pointer) is reassigned to null. This causes AutoPointer#autorelease? to fail, since reaper is now no longer.

@ghost Unknown added a commit that closed this issue
Wayne Meissner Fix #654 - FFI::AutoPointer#free causes FFI::AutoPointer#autorelease?…
… to cast NullPointerException
c253096
@ghost ghost closed this in c253096
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.