File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
branches/beta/src/libcollections Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
29
29
refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
30
30
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
31
31
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
32
- refs/heads/beta: 2cc6e8fb538d5a629501e2a55e439cf4c8f98b2c
32
+ refs/heads/beta: 1c0b2f42c86a12dd49b164ee0df97208a9cee20e
33
33
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
34
34
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
35
35
refs/heads/tmp: a224db5e630715d9f46938fe07b58eb644e3c27d
Original file line number Diff line number Diff line change @@ -616,7 +616,13 @@ impl<T> LinkedList<T> {
616
616
length : len - at
617
617
} ;
618
618
619
+ // Swap split_node.next with list_head (which is None), nulling out split_node.next,
620
+ // as it is the new tail.
619
621
mem:: swap ( & mut split_node. resolve ( ) . unwrap ( ) . next , & mut splitted_list. list_head ) ;
622
+ // Null out list_head.prev. Note this `unwrap` won't fail because if at == len
623
+ // we already branched out at the top of the fn to return the empty list.
624
+ splitted_list. list_head . as_mut ( ) . unwrap ( ) . prev = Rawlink :: none ( ) ;
625
+ // Fix the tail ptr
620
626
self . list_tail = split_node;
621
627
self . length = at;
622
628
@@ -1082,6 +1088,26 @@ mod tests {
1082
1088
}
1083
1089
}
1084
1090
1091
+ #[ test]
1092
+ fn test_26021 ( ) {
1093
+ use std:: iter:: ExactSizeIterator ;
1094
+ // There was a bug in split_off that failed to null out the RHS's head's prev ptr.
1095
+ // This caused the RHS's dtor to walk up into the LHS at drop and delete all of
1096
+ // its nodes.
1097
+ //
1098
+ // https://github.com/rust-lang/rust/issues/26021
1099
+ let mut v1 = LinkedList :: new ( ) ;
1100
+ v1. push_front ( 1u8 ) ;
1101
+ v1. push_front ( 1u8 ) ;
1102
+ v1. push_front ( 1u8 ) ;
1103
+ v1. push_front ( 1u8 ) ;
1104
+ let _ = v1. split_off ( 3 ) ; // Dropping this now should not cause laundry consumption
1105
+ assert_eq ! ( v1. len( ) , 3 ) ;
1106
+
1107
+ assert_eq ! ( v1. iter( ) . len( ) , 3 ) ;
1108
+ assert_eq ! ( v1. iter( ) . collect:: <Vec <_>>( ) . len( ) , 3 ) ;
1109
+ }
1110
+
1085
1111
#[ cfg( test) ]
1086
1112
fn fuzz_test ( sz : i32 ) {
1087
1113
let mut m: LinkedList < _ > = LinkedList :: new ( ) ;
You can’t perform that action at this time.
0 commit comments