Skip to content

Commit 298730e

Browse files
committed
Auto merge of #33960 - tbu-:pr_ref_clone_overflow, r=Aatch
Prevent the borrow counter from overflowing in `Ref::clone` Fixes #33880.
2 parents a967611 + ef60c7c commit 298730e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libcore/cell.rs

+3-1
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)