diff options
author | Tom Stellard <tstellar@redhat.com> | 2017-11-15 00:21:20 +0000 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2017-11-15 00:21:20 +0000 |
commit | 6fd1575384f68c389d4ec2894d021cbf3eafb212 (patch) | |
tree | 6650865f55a5cd2e174cd636338daf2a21623ea3 | |
parent | e3d4cdb1dd189203b9554e1f6672c098605a842a (diff) | |
download | llvm-6fd1575384f68c389d4ec2894d021cbf3eafb212.zip llvm-6fd1575384f68c389d4ec2894d021cbf3eafb212.tar.gz llvm-6fd1575384f68c389d4ec2894d021cbf3eafb212.tar.bz2 |
Merging r313776:
------------------------------------------------------------------------
r313776 | marshall | 2017-09-20 10:34:11 -0700 (Wed, 20 Sep 2017) | 1 line
Fix a bit of UB in __independent_bits_engine. Fixes PR#34663
------------------------------------------------------------------------
llvm-svn: 318236
-rw-r--r-- | libcxx/include/algorithm | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm index 4542275..00db6d7 100644 --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -3013,6 +3013,7 @@ template<class _Engine, class _UIntType> _UIntType __independent_bits_engine<_Engine, _UIntType>::__eval(true_type) { + const size_t _WRt = numeric_limits<result_type>::digits; result_type _Sp = 0; for (size_t __k = 0; __k < __n0_; ++__k) { @@ -3021,7 +3022,7 @@ __independent_bits_engine<_Engine, _UIntType>::__eval(true_type) { __u = __e_() - _Engine::min(); } while (__u >= __y0_); - if (__w0_ < _WDt) + if (__w0_ < _WRt) _Sp <<= __w0_; else _Sp = 0; @@ -3034,7 +3035,7 @@ __independent_bits_engine<_Engine, _UIntType>::__eval(true_type) { __u = __e_() - _Engine::min(); } while (__u >= __y1_); - if (__w0_ < _WDt - 1) + if (__w0_ < _WRt - 1) _Sp <<= __w0_ + 1; else _Sp = 0; |