提交 0fc1f9a2 编写于 作者: A Andrew Paseltiner

Add overflow check to `arc::Weak::upgrade`

Closes #30031.
上级 ebb560a0
......@@ -637,6 +637,11 @@ pub fn upgrade(&self) -> Option<Arc<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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册