From cb26a34548057a2d300e25eb6045d7b51551c0fe Mon Sep 17 00:00:00 2001 From: Scott Condit <19418034+t-0@users.noreply.github.com> Date: Mon, 30 Nov 2026 20:12:49 +0000 Subject: [PATCH] test_detect_cycle_with_cycle test in src/data_structures/floyds_algorithm.rs points the last node to start and follows the cycle when cleaning up --- src/data_structures/floyds_algorithm.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/data_structures/floyds_algorithm.rs b/src/data_structures/floyds_algorithm.rs index b475d07d963..e655f431b62 100644 --- a/src/data_structures/floyds_algorithm.rs +++ b/src/data_structures/floyds_algorithm.rs @@ -91,5 +91,12 @@ mod tests { assert!(has_cycle(&linked_list)); assert_eq!(detect_cycle(&linked_list), Some(3)); + + // Break the cycle so Drop doesn't walk into freed nodes + unsafe { + if let Some(mut tail) = linked_list.tail { + tail.as_mut().next = None; + } + } } }