Prevent the borrow counter from overflowing in Ref::clone
Fixes #33880.
This commit is contained in:
parent
bf9c60c9a6
commit
ef60c7cd49
1 changed files with 3 additions and 1 deletions
|
@ -618,7 +618,9 @@ impl<'b> Clone for BorrowRef<'b> {
|
|||
// Since this Ref exists, we know the borrow flag
|
||||
// is not set to WRITING.
|
||||
let borrow = self.borrow.get();
|
||||
debug_assert!(borrow != WRITING && borrow != UNUSED);
|
||||
debug_assert!(borrow != UNUSED);
|
||||
// Prevent the borrow counter from overflowing.
|
||||
assert!(borrow != WRITING);
|
||||
self.borrow.set(borrow + 1);
|
||||
BorrowRef { borrow: self.borrow }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue