about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-11-25 09:21:19 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-11-25 09:21:19 +0530
commit529689f0dc7b877b7e47cee53d66af2e97664a4d (patch)
treee923d49049fd2834939f3b9afe6ad7f02bab8178 /src/liballoc
parent3f25c5c655ed54ee09f8018029aedad9dde797bd (diff)
parent0fc1f9a2edda6c08fb0857e780b49102420a4179 (diff)
downloadrust-529689f0dc7b877b7e47cee53d66af2e97664a4d.tar.gz
rust-529689f0dc7b877b7e47cee53d66af2e97664a4d.zip
Rollup merge of #30040 - apasel422:issue-30031, r=brson
Closes #30031.
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/arc.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs
index dba9b71c61c..45a47ae075e 100644
--- a/src/liballoc/arc.rs
+++ b/src/liballoc/arc.rs
@@ -637,6 +637,11 @@ impl<T: ?Sized> Weak<T> {
                 return None
             }
 
+            // See comments in `Arc::clone` for why we do this (for `mem::forget`).
+            if n > MAX_REFCOUNT {
+                unsafe { abort(); }
+            }
+
             // Relaxed is valid for the same reason it is on Arc's Clone impl
             let old = inner.strong.compare_and_swap(n, n + 1, Relaxed);
             if old == n {