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
More Robust Null Terminator Handling #52
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Steam too, now? Argh. Thanks.
@Ralith this wasn't historically a problem (for me) but started in SteamVR beta |
openxr/src/lib.rs
Outdated
// Strip null byte | ||
bytes.truncate(bytes.len() - 1); | ||
// Truncate at first null byte | ||
let first_nt = bytes.iter().position(|&x| x == 0).expect("missing null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let first_nt = bytes.iter().position(|&x| x == 0).expect("missing null"); | |
let first_nt = bytes.iter().rposition(|&x| x != 0).expect("missing null") + 1; |
Makes more sense to search from the end.
In most recent SteamVR beta OpenXR calls can return values with multiple null terminators. This will cause the existing solution to remove only the final terminator. This commit adds a more robust check to truncate on the first occurrence of null terminator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
In most recent SteamVR beta OpenXR calls can return values with multiple
null terminators. This will cause the existing solution to remove only
the final terminator. This commit adds a more robust check to truncate
on the first occurrence of null terminator.
Closes #47