Skip to content

Windows: ensure buffer passed to HidD_SetFeature is large enough #224

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

Merged
merged 2 commits into from
Dec 24, 2020

Conversation

Mornix
Copy link
Contributor

@Mornix Mornix commented Dec 13, 2020

HidD_SetFeature() requires a feature report be at least a certain size similar to the requirement for WriteFile() in the implementation of hid_write().

@Youw
Copy link
Member

Youw commented Dec 16, 2020

Thanks, this is good.
Do you mind making a small change?
Cache the buffer as a device member, and allocate it only on first use.
An optimisation, so we don't do dynamica allocations on each report.

I wanted to apply same optimisation for hid_write to, just didn't have a chance to do so yet.

Copy link
Member

@Youw Youw left a comment

Choose a reason for hiding this comment

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

Nice!
This is exactly how I'd do it.

@Youw Youw merged commit fb4135c into libusb:master Dec 24, 2020
@mcuee mcuee added the Windows Related to Windows backend label Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows Related to Windows backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants