commit | 7023194c8d11a081fd01ed25308b3d60193c6a06 | [log] [tgz] |
---|---|---|
author | Dan Albert <danalbert@google.com> | Mon Jan 08 21:49:12 2018 +0000 |
committer | Dan Albert <danalbert@google.com> | Mon Jan 08 21:49:12 2018 +0000 |
tree | bc234a173d3c0f48e2888f5550316b586e7cb1d3 | |
parent | 4d8cc6db101bc59685231fccd6fff6ca665629d7 [diff] |
Make rehash(0) work with ubsan's unsigned-integer-overflow. Reviewers: mclow.lists, EricWF Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D40743 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322031 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/__hash_table b/include/__hash_table index 3f430af..2394152 100644 --- a/include/__hash_table +++ b/include/__hash_table
@@ -2136,7 +2136,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n) { - if (__n == 1) + if (__n < 2) __n = 2; else if (__n & (__n - 1)) __n = __next_prime(__n);