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

prevent panic when call read_control() #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/device_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ impl<'a> DeviceHandle<'a> {
/// This function returns a list of languages that can be used to read the device's string
/// descriptors.
pub fn read_languages(&self, timeout: Duration) -> ::Result<Vec<Language>> {
let mut buf = Vec::<u8>::with_capacity(256);
let mut buf = Vec::<u8>::with_capacity(255);

let mut buf_slice = unsafe {
slice::from_raw_parts_mut((&mut buf[..]).as_mut_ptr(), buf.capacity())
Expand All @@ -428,7 +428,7 @@ impl<'a> DeviceHandle<'a> {
///
/// `language` should be one of the languages returned from [`read_languages`](#method.read_languages).
pub fn read_string_descriptor(&self, language: Language, index: u8, timeout: Duration) -> ::Result<String> {
let mut buf = Vec::<u8>::with_capacity(256);
let mut buf = Vec::<u8>::with_capacity(255);

let mut buf_slice = unsafe {
slice::from_raw_parts_mut((&mut buf[..]).as_mut_ptr(), buf.capacity())
Expand Down