about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-05-30 23:09:00 -0700
committerbors <bors@rust-lang.org>2016-05-30 23:09:00 -0700
commit298730e7032cd55809423773da397cd5c7d827d4 (patch)
tree08e8ae40f370e0fc45e1279bb7d30df8635e8c28 /src
parenta967611d8ffececb5ed0ecf6a205b464d7a5a31e (diff)
parentef60c7cd49d80ef3f1f6a7030d4439024359f37a (diff)
downloadrust-298730e7032cd55809423773da397cd5c7d827d4.tar.gz
rust-298730e7032cd55809423773da397cd5c7d827d4.zip
Auto merge of #33960 - tbu-:pr_ref_clone_overflow, r=Aatch
Prevent the borrow counter from overflowing in `Ref::clone`

Fixes #33880.
Diffstat (limited to 'src')
-rw-r--r--src/libcore/cell.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs
index 4929088201d..97a85f6aa43 100644
--- a/src/libcore/cell.rs
+++ b/src/libcore/cell.rs
@@ -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 }
     }