Skip to content

Commit 05bac66

Browse files
committed
Sanitizer fix: shift exponent too large
lib/vf_common.cpp:115:96: runtime error: shift exponent 18446744073709550144 is too large for 64-bit type 'long long unsigned int' lib/vf_common.cpp:116:47: runtime error: shift exponent 1919 is too large for 64-bit type 'long long unsigned int'
1 parent e1cc0e2 commit 05bac66

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

lib/vf_common.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <limits>
3939
#include <utility>
4040
#include <vector>
41+
#include <algorithm>
4142

4243
namespace ValueFlow
4344
{
@@ -101,6 +102,9 @@ namespace ValueFlow
101102
if (value_size == 0)
102103
return value;
103104

105+
// sizeof(long long) = 8
106+
value_size = std::min(sizeof(long long), value_size);
107+
104108
const MathLib::biguint unsignedMaxValue = std::numeric_limits<MathLib::biguint>::max() >> ((sizeof(unsignedMaxValue) - value_size) * 8);
105109
const MathLib::biguint signBit = 1ULL << (value_size * 8 - 1);
106110
value &= unsignedMaxValue;

0 commit comments

Comments
 (0)