1
0
Fork 0

Undefined Behavior fix.

Shifting bits into the sign-bit is unpredictable.
Should be an unsigned type.
This commit is contained in:
Scott Giese 2021-12-26 12:38:08 -06:00
parent 560e7a3d12
commit 3850700ce1
2 changed files with 2 additions and 2 deletions

View file

@ -44,7 +44,7 @@ static void writeRaw(std::ostream& out, const T& data)
// Reads uncompressed vector<char> from file. Throws if length field is longer
// than <max_length>.
template<typename SizeType>
static SizeType VectorRead(std::istream& in, std::vector<char>& out, uint32_t max_length=(1<<31))
static SizeType VectorRead(std::istream& in, std::vector<char>& out, uint32_t max_length=(1u << 31))
{
SizeType length;
readRaw(in, length);

View file

@ -115,7 +115,7 @@ int jsInput::getInput() {
}
if(button_bits != 0) {
for(int i=0;i<=31;i++) {
if( ( button_bits & (1 << i) ) > 0 ) {
if( ( button_bits & (1u << i) ) > 0 ) {
button=i;
break;
}