fix undefined behavior in shift

This commit is contained in:
Arvid Norberg 2015-04-29 04:23:00 +00:00
parent 8aa3c22796
commit 73a24ffc0e
1 changed files with 5 additions and 3 deletions

View File

@ -124,9 +124,11 @@ namespace libtorrent
if (m_buf[i] != 0xffffffff) return false;
}
int rest = size() & 31;
boost::uint32_t mask = htonl(0xffffffff << (32-rest));
if (rest > 0 && (m_buf[words] & mask) != mask)
return false;
if (rest > 0)
{
boost::uint32_t mask = htonl(0xffffffff << (32-rest));
if ((m_buf[words] & mask) != mask) return false;
}
return true;
}