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

Remove null terminators from other extensions #159

Merged
Merged
Show file tree
Hide file tree
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
11 changes: 8 additions & 3 deletions generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,7 @@ impl Parser {

#![allow(clippy::wrong_self_convention, clippy::transmute_ptr_to_ptr)]
use std::borrow::Cow;
use std::ffi::CStr;
use std::mem::MaybeUninit;
pub use sys::{#(#reexports),*};
pub use sys::platform::{EGLenum, VkFilter, VkSamplerMipmapMode, VkSamplerAddressMode, VkComponentSwizzle};
Expand All @@ -1517,9 +1518,13 @@ impl Parser {
match crate::fixed_str_bytes(&ext.extension_name) {
#(#ext_set_inits)*
bytes => {
if let Ok(name) = std::str::from_utf8(bytes) {
out.other.push(name.into());
}
let cstr = CStr::from_bytes_with_nul(bytes)
.expect("extension names should be null terminated strings");
let string = cstr
.to_str()
.expect("extension names should be valid UTF-8")
.to_string();
out.other.push(string);
}
}
}
Expand Down
11 changes: 8 additions & 3 deletions openxr/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![allow(clippy::wrong_self_convention, clippy::transmute_ptr_to_ptr)]
use crate::*;
use std::borrow::Cow;
use std::ffi::CStr;
use std::mem::MaybeUninit;
pub use sys::platform::{
EGLenum, VkComponentSwizzle, VkFilter, VkSamplerAddressMode, VkSamplerMipmapMode,
Expand Down Expand Up @@ -686,9 +687,13 @@ impl ExtensionSet {
out.htcx_vive_tracker_interaction = true;
}
bytes => {
if let Ok(name) = std::str::from_utf8(bytes) {
out.other.push(name.into());
}
let cstr = CStr::from_bytes_with_nul(bytes)
.expect("extension names should be null terminated strings");
let string = cstr
.to_str()
.expect("extension names should be valid UTF-8")
.to_string();
out.other.push(string);
}
}
}
Expand Down
Loading