Skip to content

Commit

Permalink
Prevent the borrow counter from overflowing in Ref::clone
Browse files Browse the repository at this point in the history
Fixes #33880.
  • Loading branch information
tbu- committed May 30, 2016
1 parent bf9c60c commit ef60c7c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/libcore/cell.rs
Expand Up @@ -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 }
}
Expand Down

0 comments on commit ef60c7c

Please sign in to comment.