Auto merge of #37605 - dsprenkels:arc-max-refcount, r=alexcrichton
Fix Arc::clone()'s MAX_REFCOUNT check (off-by-one) Before, the strong count of an `Arc` could be set to `MAX_REFCOUNT + 1`, because when this happened, `old_size` would be exactly `MAX_REFCOUNT`. `Arc::clone()` would not abort. This commit changes the check in `Arc::clone()` to also abort if the old value is equal to `MAX_REFCOUNT`, because then the new value will be equal to `MAX_REFCOUNT + 1`. A test would require allocating memory for `isize::MAX` pointers. This would probably crash any machine, so no test is submitted with this commit.
Showing
想要评论请 注册 或 登录