1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2024-12-16 16:35:45 +00:00

Make get_bits_value() more robust

This commit is contained in:
Xorg 2016-05-18 16:51:38 +02:00
parent 1d5ac6f23f
commit 841c975e95

View file

@ -438,7 +438,7 @@ uint64_t get_bits_value(uint64_t val, int highbit, int lowbit)
uint64_t data = val;
const uint8_t bits = highbit - lowbit + 1;
if(bits < 64) {
if(bits < 64 && highbit < 64 && lowbit < highbit) {
/* Show only part of register */
data >>= lowbit;
data &= (1ULL << bits) - 1;