summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2024-02-18 22:01:29 +0300
committerOxore <oxore@protonmail.com>2024-02-18 22:01:29 +0300
commit3ae20774096ddb42ea03142d0c55f9564da4ba50 (patch)
tree989e1c6c4e28996ba61250c935b563896c512e8a
parentfec4c1684e8680285f51ebd4898fe35127c7e098 (diff)
Fix runtime error in regmask printing routine
-rw-r--r--src/disasm.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/disasm.cpp b/src/disasm.cpp
index be4a9a8..3a27400 100644
--- a/src/disasm.cpp
+++ b/src/disasm.cpp
@@ -1791,7 +1791,9 @@ static size_t snprint_reg_mask(
size_t span = 0;
// 17-th bit used to close the span with 0 value unconditionally
for (int i = 0; i < 17; i++) {
- const uint32_t mask = 1 << (arg_type == ArgType::kRegMaskPredecrement ? (15 - i) : i);
+ const uint32_t mask = (i <= 15)
+ ? (1 << ((arg_type == ArgType::kRegMaskPredecrement) ? (15 - i) : i))
+ : 0;
const bool hit = regmask & mask;
const bool span_open = hit && span == 0;
const bool span_closed = !hit && span > 1;