From e25f4f2af6e5e522f8b6ad0ca0b84f607a73cae2 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 16 Jun 2024 17:59:49 +0200 Subject: fix(ecs): prevent archetype creation from causing oob memory accesses --- ecs/src/query.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'ecs/src/query.rs') diff --git a/ecs/src/query.rs b/ecs/src/query.rs index a2edc4d..dcd0b0e 100644 --- a/ecs/src/query.rs +++ b/ecs/src/query.rs @@ -2,10 +2,9 @@ use std::any::{type_name, Any}; use std::collections::HashSet; use std::iter::{Flatten, Map}; use std::marker::PhantomData; -use std::slice::Iter as SliceIter; use std::sync::{Arc, Weak}; -use crate::component::storage::Archetype; +use crate::component::storage::{Archetype, ArchetypeRefIter}; use crate::component::{ Id as ComponentId, IsOptional as ComponentIsOptional, @@ -46,7 +45,6 @@ where .component_storage .find_entities(&Comps::ids()) .unwrap_or_else(|| panic!("Could not find {:?}", type_name::())) - .iter() .map((|archetype| archetype.components.as_slice()) as ComponentIterMapFn) .flatten(), comps_pd: PhantomData, @@ -218,11 +216,11 @@ where } } -type ComponentIterMapFn = for<'a> fn(&'a &'a Archetype) -> &'a [Vec]; +type ComponentIterMapFn = for<'a> fn(&'a Archetype) -> &'a [Vec]; pub struct ComponentIter<'world, Comps> { - entities: Flatten, ComponentIterMapFn>>, + entities: Flatten, ComponentIterMapFn>>, comps_pd: PhantomData, } -- cgit v1.2.3-18-g5258