Skip to content

Commit fc5e16e

Browse files
Review
1 parent 4f1b948 commit fc5e16e

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

‎crates/capi/src/slots.rs‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ impl PySlot {
5151
pub(crate) fn iter<'a>(slots: *const Self) -> impl Iterator<Item = Cow<'a, Self>> {
5252
let mut stack: Vec<Either<*const Self, *const PyType_Slot>> = vec![Either::Left(slots)];
5353
core::iter::from_fn(move || {
54+
if stack.len() > 10 {
55+
panic!("Too many nested slots, possible infinite loop in slot iteration");
56+
}
5457
loop {
5558
return match stack.last_mut()? {
5659
Either::Left(slot_ptr) => {
@@ -187,6 +190,7 @@ impl PySlot {
187190
}
188191

189192
#[repr(C)]
193+
#[derive(Copy, Clone)]
190194
pub union PySlotValue {
191195
pub sl_ptr: *mut c_void,
192196
pub sl_func: unsafe extern "C" fn(),
@@ -195,14 +199,6 @@ pub union PySlotValue {
195199
pub sl_uint64: u64,
196200
}
197201

198-
impl Clone for PySlotValue {
199-
fn clone(&self) -> Self {
200-
Self {
201-
sl_ptr: unsafe { self.sl_ptr },
202-
}
203-
}
204-
}
205-
206202
impl<T> From<*mut T> for PySlotValue {
207203
fn from(ptr: *mut T) -> Self {
208204
Self { sl_ptr: ptr.cast() }

0 commit comments

Comments
 (0)