mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-21 22:34:43 +00:00
fix null handling of array fields in autogen properties (#2518)
* add UnalignedSlice
* Revert "add UnalignedSlice"
This reverts commit 8bb1603ed3
.
* add null check
* clippy
* rerun ci
This commit is contained in:
parent
7827b6b22a
commit
3fb4a30a9f
@ -92,14 +92,19 @@ fn properties_output(members: &[PropertiesMember]) -> TokenStream {
|
||||
let len_field_name = Ident::new(len_field_name.as_str(), Span::call_site());
|
||||
|
||||
quote! {
|
||||
properties_ffi.#ffi_member.map(|s|
|
||||
unsafe {
|
||||
properties_ffi.#ffi_member.and_then(|s| {
|
||||
let ptr = s #ffi_member_field .#ffi_name .cast_const();
|
||||
if ptr.is_null() {
|
||||
return None;
|
||||
};
|
||||
|
||||
Some(unsafe {
|
||||
std::slice::from_raw_parts(
|
||||
s #ffi_member_field .#ffi_name .cast_const(),
|
||||
ptr,
|
||||
s #ffi_member_field .#len_field_name as _,
|
||||
)
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
} else {
|
||||
quote! { properties_ffi.#ffi_member.map(|s| s #ffi_member_field .#ffi_name) }
|
||||
|
Loading…
Reference in New Issue
Block a user