Skip to content

Commit

Permalink
Auto merge of #33960 - tbu-:pr_ref_clone_overflow, r=Aatch
Browse files Browse the repository at this point in the history
Prevent the borrow counter from overflowing in `Ref::clone`

Fixes #33880.
  • Loading branch information
bors committed May 31, 2016
2 parents a967611 + ef60c7c commit 298730e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/libcore/cell.rs
Original file line number Diff line number Diff line change
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 298730e

Please sign in to comment.