Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int64_t set_vch(const std::vector<unsigned char>& vch)
- {
- if (vch.empty())
- return 0;
- int64_t result = 0;
- for (size_t i = 0; i != vch.size(); ++i)
- result |= static_cast<int64_t>(vch[i]) << 8*i;
- // If the input vector's most significant byte is 0x80,
- // remove it from the result's msb and return a negative.
- if (vch.back() & 0x80)
- return -(result & ~(0x80 << (8 * (vch.size() - 1))));
- return result;
- }
- This suspicious code was found in Bitcoin project by PVS-Studio static code analyzer.
- Warning message is:
- V629 Consider inspecting the '0x80 << (8 * (vch.size() - 1))' expression. Bit shifting of the 32-bit value with a subsequent expansion to the 64-bit type. script.h 169
- PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment