Skip to content

Commit

Permalink
Fix unreferencing LIBUSB::Context from Call::Transfer
Browse files Browse the repository at this point in the history
The unref Context was sent to the wrong object.
This prevented freeing of Context objects, as soon as a transfer was executed.
  • Loading branch information
larskanis committed Apr 20, 2024
1 parent 8bd6507 commit 9617c68
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/libusb/transfer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def dev_handle=(dev)
# Now that the transfer is bound to a DevHandle, it must be registered in the Context.
# This ensures that the Call::Transfer is freed before libusb_exit, avoiding warnings about still referenced devices.
ctx = dev.device.context.instance_variable_get(:@ctx)
@transfer.instance_variable_set(:@ctx, ctx.ref_context)
@transfer.pointer.instance_variable_set(:@ctx, ctx.ref_context)
end

# The handle for the device to communicate with.
Expand Down

0 comments on commit 9617c68

Please sign in to comment.