Skip to content

Fix memory leaks in fakelibusb_test.go - #139

Open
BryanDClark wants to merge 4 commits into
google:masterfrom
BryanDClark:master
Open

Fix memory leaks in fakelibusb_test.go#139
BryanDClark wants to merge 4 commits into
google:masterfrom
BryanDClark:master

Conversation

@BryanDClark

Copy link
Copy Markdown

No description provided.

Comment thread fakelibusb_test.go
freeDevicePointer(d)
delete(f.devices, d)
}
for h := range f.handles {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like the handling of "handles" should be similar to the transfers - they should not be freed silently, but rather should be reported as a missing close on the handle?

Comment thread libusb.go
return (*libusbDevHandle)(unsafe.Pointer(C.malloc(1)))
}

func freeDevicePointer(d *libusbDevice) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should go into the test code, we don't touch these pointers directly in non-test code.

Also add a block comment why these helpers are needed, something along the lines of "in tests, the code allocates some C pointers directly, it needs to be able to free them directly too".

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

Successfully merging this pull request may close these issues.

2 participants