mirror of
https://github.com/anrieff/libcpuid
synced 2025-07-02 14:04:15 +00:00
Make get_bits_value() more robust
This commit is contained in:
parent
1d5ac6f23f
commit
841c975e95
1 changed files with 1 additions and 1 deletions
|
@ -438,7 +438,7 @@ uint64_t get_bits_value(uint64_t val, int highbit, int lowbit)
|
||||||
uint64_t data = val;
|
uint64_t data = val;
|
||||||
const uint8_t bits = highbit - lowbit + 1;
|
const uint8_t bits = highbit - lowbit + 1;
|
||||||
|
|
||||||
if(bits < 64) {
|
if(bits < 64 && highbit < 64 && lowbit < highbit) {
|
||||||
/* Show only part of register */
|
/* Show only part of register */
|
||||||
data >>= lowbit;
|
data >>= lowbit;
|
||||||
data &= (1ULL << bits) - 1;
|
data &= (1ULL << bits) - 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue