Skip to content

Commit fd85e4e

Browse files
committed
kms: Don't incorrectly re-use iterator in update_surface_nodes
1 parent 6492629 commit fd85e4e

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/backend/kms/device.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ impl InnerDevice {
872872
pub fn update_surface_nodes<'b>(
873873
&mut self,
874874
used_devices: &HashSet<DrmNode>,
875-
mut others: impl Iterator<Item = &'b Self>,
875+
others: &[&'b mut Self],
876876
) -> Result<()>
877877
where
878878
Self: 'b,
@@ -891,7 +891,10 @@ impl InnerDevice {
891891
self.gbm.clone(),
892892
)
893893
} else {
894-
let device = others.find(|d| d.render_node == *new_device).unwrap();
894+
let device = others
895+
.iter()
896+
.find(|d| d.render_node == *new_device)
897+
.unwrap();
895898
(
896899
device.render_node,
897900
device.egl.as_ref().unwrap(),

src/backend/kms/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,9 @@ impl KmsState {
571571
let (mut device, others) = self
572572
.drm_devices
573573
.values_mut()
574-
.partition::<Vec<_>, _>(|d| d.inner.render_node == node);
575-
device[0]
576-
.inner
577-
.update_surface_nodes(&used_devices, others.iter().map(|device| &device.inner))?;
574+
.map(|d| &mut d.inner)
575+
.partition::<Vec<_>, _>(|d| d.render_node == node);
576+
device[0].update_surface_nodes(&used_devices, &others)?;
578577
}
579578

580579
Ok(())
@@ -634,10 +633,9 @@ impl<'a> KmsGuard<'a> {
634633
let (mut device, others) = self
635634
.drm_devices
636635
.values_mut()
637-
.partition::<Vec<_>, _>(|d| d.inner.render_node == node);
638-
device[0]
639-
.inner
640-
.update_surface_nodes(&used_devices, others.iter().map(|device| &*device.inner))?;
636+
.map(|d| &mut *d.inner)
637+
.partition::<Vec<_>, _>(|d| d.render_node == node);
638+
device[0].update_surface_nodes(&used_devices, &others)?;
641639
}
642640

643641
Ok(())

0 commit comments

Comments
 (0)