Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Burgestrand opened this issue Apr 24, 2013 · 0 comments
Milestone

Comments

@Burgestrand
Copy link

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 ghost closed this as completed in c253096 Apr 24, 2013
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant