From 3850700ce176157425fd485a9206bac70a8481bf Mon Sep 17 00:00:00 2001 From: Scott Giese Date: Sun, 26 Dec 2021 12:38:08 -0600 Subject: [PATCH] Undefined Behavior fix. Shifting bits into the sign-bit is unpredictable. Should be an unsigned type. --- src/Aircraft/continuous.cxx | 2 +- src/Input/jsinput.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Aircraft/continuous.cxx b/src/Aircraft/continuous.cxx index 83e11e343..da338673c 100644 --- a/src/Aircraft/continuous.cxx +++ b/src/Aircraft/continuous.cxx @@ -44,7 +44,7 @@ static void writeRaw(std::ostream& out, const T& data) // Reads uncompressed vector from file. Throws if length field is longer // than . template -static SizeType VectorRead(std::istream& in, std::vector& out, uint32_t max_length=(1<<31)) +static SizeType VectorRead(std::istream& in, std::vector& out, uint32_t max_length=(1u << 31)) { SizeType length; readRaw(in, length); diff --git a/src/Input/jsinput.cxx b/src/Input/jsinput.cxx index 0fbce4b16..561d1a4fa 100644 --- a/src/Input/jsinput.cxx +++ b/src/Input/jsinput.cxx @@ -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; }