Skip to content

Commit ef60c7c

Browse files
committed
Prevent the borrow counter from overflowing in Ref::clone
Fixes #33880.
1 parent bf9c60c commit ef60c7c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libcore/cell.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,9 @@ impl<'b> Clone for BorrowRef<'b> {
618618
// Since this Ref exists, we know the borrow flag
619619
// is not set to WRITING.
620620
let borrow = self.borrow.get();
621-
debug_assert!(borrow != WRITING && borrow != UNUSED);
621+
debug_assert!(borrow != UNUSED);
622+
// Prevent the borrow counter from overflowing.
623+
assert!(borrow != WRITING);
622624
self.borrow.set(borrow + 1);
623625
BorrowRef { borrow: self.borrow }
624626
}

0 commit comments

Comments
 (0)