mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-22 15:31:03 +01:00
Panic to prevent arena Handle overflow (#667)
* Panic to prevent arena Handle overflow * Use `NonZeroU32::new` to detect overflow
This commit is contained in:
1 parent
0058ce5a7d
commit
ccb6dc9088
1 file changed
+2
-1
+2
-1
@@ -189,7 +189,8 @@ impl<T> Arena<T> {
|
||||
/// Adds a new value to the arena, returning a typed handle.
|
||||
pub fn append(&mut self, value: T) -> Handle<T> {
|
||||
let position = self.data.len() + 1;
|
||||
let index = unsafe { Index::new_unchecked(position as u32) };
|
||||
let index =
|
||||
Index::new(position as u32).expect("Failed to append to Arena. Handle overflows");
|
||||
self.data.push(value);
|
||||
Handle::new(index)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user