Prevent potential undefined behavior by shifting by a wrapped uint.

Found by clang static analyzer.
This commit is contained in:
John Ralls 2018-11-28 15:37:25 +09:00
parent 606d9cfee6
commit 3d1362757b

View File

@ -374,6 +374,8 @@ GncInt128&
GncInt128::operator<<= (unsigned int i) noexcept GncInt128::operator<<= (unsigned int i) noexcept
{ {
auto flags = get_flags(m_hi); auto flags = get_flags(m_hi);
if (i == 0)
return *this;
if (i > maxbits) if (i > maxbits)
{ {
flags &= 0xfe; flags &= 0xfe;