From cbbd06795ceae4386d0ac6c45095db2720f05d36 Mon Sep 17 00:00:00 2001 From: James Johnson Date: Mon, 20 Oct 2025 21:09:29 -0400 Subject: [PATCH] Fix calculation of mask for constant values This fixes an error when a constant is being loaded into a flag. The constants associated with a flag value have their size set to zero. That causes the mask for the constant value to be all zeros. Due to that, getting the value of a zero sized constant will always return 0 even if it should be 1. This commit special cases the size of zero to create a mask of 1 which will correctly mask off the lowest byte and return that as the constant. --- rust/src/low_level_il/operation.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/rust/src/low_level_il/operation.rs b/rust/src/low_level_il/operation.rs index 419a0dcd9..fa320060f 100644 --- a/rust/src/low_level_il/operation.rs +++ b/rust/src/low_level_il/operation.rs @@ -1754,12 +1754,14 @@ where } } - let mut mask = -1i64 as u64; - - if self.op.size < mem::size_of::() { - mask <<= self.op.size * 8; - mask = !mask; - } + let mask: u64 = if self.op.size == 0 { + 1 + } else if self.op.size < mem::size_of::() { + let m = -1i64 << (self.op.size * 8); + !m as u64 + } else { + (-1i64) as u64 + }; self.op.operands[0] & mask }