mirror of
https://github.com/bevyengine/bevy
synced 2024-11-14 00:47:32 +00:00
3ac06b57e9
# Objective Fixes #6615. `BlobVec` does not respect alignment for zero-sized types, which results in UB whenever a ZST with alignment other than 1 is used in the world. ## Solution Add the fn `bevy_ptr::dangling_with_align`. --- ## Changelog + Added the function `dangling_with_align` to `bevy_ptr`, which creates a well-aligned dangling pointer to a type whose alignment is not known at compile time. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |
bevy_ptr
The bevy_ptr
crate provides low-level abstractions for working with pointers in a more safe way than using rust's raw pointers.
Rust has lifetimed and typed references (&'a T
), unlifetimed and typed references (*const T
), but no lifetimed but untyped references.
bevy_ptr
adds them, called Ptr<'a>
, PtrMut<'a>
and OwningPtr<'a>
.
These types are lifetime-checked so can never lead to problems like use-after-frees and must always point to valid data.